Represents Alternative object.
Properties:
Name | Type | Description |
---|---|---|
code | String | Alternative item code specified by the questionnaire author. It must be unique within the question. |
name | String | Alternative item display text. |
order | Number | Alternative position in question. |
other | Boolean | Indicates whether alternative is other or not. |
exclusive | Boolean | Indicates whether alternative is exclusive or not. |
subheader | Boolean | Indicates whether alternative is subheader or not. |
numeric | Boolean | Indicates whether alternative is numeric or not. Works for other alternatives |
numericMin | Number | Indicates minimum value of numeric alternative. |
numericMax | Number | Indicates maximum value of numeric alternative. |
keepposition | Boolean | Indicates whether alternative should keep position or not. Used when the alternatives are shown sporadically. |
hideName | Boolean | Do not show alternative text to respondents. |
mediaPath | String | Path to attached media file. |
Example
//indicate that alternative a1 of q1 question is numeric
q.q1.a1.other = true;
q.q1.a1.numeric = true;
Methods
(inner)get()→ {String}
- Depending of question type returns the alternative code or answer value.
Returns:
- Type
- String
(inner)getOther()→ {String|Number}
- Returns answer value for "other" alternative
Returns:
- Type
- String | Number
(inner)hide()
- Hides alternative. If all alternatives of the question are hidden the question become hidden too.
(inner)insertAfter(code)
- Move selected alternaitve after the target alternative.
Parameters:
Name Type Description code
String alternaitve code (inner)insertBefore(code)
- Move selected alternaitve before the target alternative.
Parameters:
Name Type Description code
String alternaitve code Example
//insert alternative with code "a5" before alternative with code "a2" q.q1.a5.insertBefore('a2');
(inner)isVisible()→ {Boolean}
- Checks if specific Alternative is visible.
Returns:
- Type
- Boolean
(inner)set(value)
- Sets alternative value
Parameters:
Name Type Description value
Boolean | String | Number Example
//set "a1" alternative selected in "q1" question q.q1.a1.set(); // or q.q1.a1.set(true); // set value for "a1" alternative of "other" type in "q1" question q.q1.a1.set("Answer Text");
(inner)show()
- Shows alternative.
(inner)toggle()
- Changes visibilty of the alternative.
If Alternative is initially displayed, it will be hidden; if hidden, it will be shown.
Example
//change a1 alternative visibility to opposite q.q1.a1.toggle();