Introduction


This namespace contains inputs manipulation functions. It's divided into 3 sections:

  • General input functions: functions for inputs in general
  • Select functions: functions for select input
  • Check-able functions: functions for checkboxes and radio buttons

General Input Functions



spa.input.getValue(input)


Get input value.

Parameter Type Description
input string | JQuery Input as jQuery selector string or as JQuery object

spa.input.getFiles(input)


For input of type file, get selected files.

Parameter Type Description
input string | JQuery Input as jQuery selector string or as JQuery object

spa.input.setValue(input, value)


Set input value and trigger change event.

Parameter Type Description
input string | JQuery Input as jQuery selector string or as JQuery object
value string The value to be set

Select Functions



spa.input.select.getSelectedOption(select)


Get the selected option as Jquery object.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.getSelectedValue(select)


Get the value of the selected option.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.getSelectedText(select)


Get the text of the selected option.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.getSelectedIndex(select)


Get the selected option index.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.setSelectedIndex(select, index)


Set option by index.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object
index integer Index to be selected

spa.input.select.setSelectedValue(select, value)


Set option by value.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object
value string The value of option to be selected

spa.input.select.setFirstOptionSelected(select)


Set the first option as the selected option.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.clearOptions(select)


Clear all options.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object

spa.input.select.addOptions(select, options, removeCurrent, firstOptionLabel)


Add multiple options to select input.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object
options array Array of objects that represent the new options. Each object represent one option and should have text and value attributes as follow:
{
    text: 'option name',
    value: 'option value'
}
removeCurrent boolean Whereas to keep previous options or remove them.
firstOptionLabel string This optional parameter is used to generate the first option. This first option is selected, disabled and has no value

spa.input.select.addOption(select, option, isSelected)


Add new option the end of select options.

Parameter Type Description
select string | JQuery Select input as jQuery selector string or as JQuery object
option object This object represents the option to be added and should have text and value attributes as follow:
{
    text: 'option name',
    value: 'option value'
}
isSelected boolean This value indicate if the new option should be selected or not

Check-able Functions


Check-able functions is used to manipulate checkbox and radio button inputs.


spa.input.checkable.isChecked(input)


Check whereas the input (checkbox or radio button) is checked or not.

Parameter Type Description
input string | JQuery The input (checkbox or radio button) as jQuery selector string or as JQuery object

spa.input.checkable.set(input, status)


Set the input (checkbox or radio button) checked status.

Parameter Type Description
input string | JQuery The input (checkbox or radio button) as jQuery selector string or as JQuery object
status boolean Checked status to be set

spa.input.checkable.getRadioGroupValue(name)


Sometime we have a group of radio buttons with the same name but with different values. To get the selected value from this group we use spa.input.checkable.getRadioGroupValue(name)

Parameter Type Description
name string The unified name of radio buttons in a given group.

spa.input.checkable.getCheckboxGroupArray(name)


Sometime we have a group of checkboxes with the same name (usually using array syntax: checkBoxName[] ) but with different values. To get array of checked checkboxes value from this group we use spa.input.checkable.getCheckboxGroupArray(name)

Parameter Type Description
name string The unified name of checkboxes in a given group.