Each item in the answer list of a multi, ranking, open text list, numeric list or grid can be referenced with syntax quite similar to the syntax for referencing the items in an array. But instead of a numeric index starting at zero, you refer to the elements of a multi or a grid by using the code of the element. The code is a string. In the follow examples, the result will be the item with code "3" in the multi or grid q1:
JScript example:
f("q1")["3"]JavaScript example:
f("q1").item("3")When you use this syntax to access an element of a grid or a multi, you can use the following methods:
get,set,labelandgetTypefor the elements of a multi, ranking, open text list or numeric list question.labelwill then give the label of the answer in the current language.getTypewill return "DICHOTOMY" if it is a multi, "NUMERIC" if it is a numeric list, and "OPEN" if it is any of the other types.get,set,label,value,valueLabel,domainValues,domainLabelsfor the elements of a grid question.labelwill then give the label of the answer (from the answer list) in the current language.valuewill return the code of the answer (from the scale) to that element of the grid.valueLabelwill return the corresponding answer text (from the scale) in the current language.domainValuesanddomainLabelswill respectively return all possible codes from the scale and the corresponding labels (answers) from the scale in the current language.getTypewill return "CODED".
Using the same multi and grid from the previous example, the examples below can be used on the single elements of a multi or a grid.
Element of a Grid Question
JScript example:
f("importance")["3"].get(): 2
f("importance")["3"].label(); Color
f("importance")["3"].value(): 2
f("importance")["3"].valueLabel(): Somewhat Important
f("importance")["3"].domainValues(): 1,2,3,4
f("importance")["3"].domainLabels(): Not Important,Somewhat Important,Important,Very Important
f("importance")["3"].getType(): CODEDJavaScript example:
f("importance").item("3").get(): 2
f("importance").item("3").label(); Color
f("importance").item("3").value(): 2
f("importance").item("3").valueLabel(): Somewhat Important
f("importance").item("3").domainValues(): 1,2,3,4
f("importance").item("3").domainLabels(): Not Important,Somewhat Important,Important,Very Important
f("importance").item("3").getType(): CODEDElement of a Multi Question
JScript example:
f("cars")["3"].get():1
f("cars")["3"].label(): BMW
f("cars")["3"].getType(): DICHOTOMYJavaScript example:
f("cars").item("3").get():1
f("cars").item("3").label(): BMW
f("cars").item("3").getType(): DICHOTOMYElement of an Open Text List Question
JScript example:
f("carscharacteristics")["3"].get(): Innovative
f("carscharacteristics")["3"].label(): BMW
f("carscharacteristics")["3"].getType(): OPENJavaScript example:
f("carscharacteristics").item("3").get(): Innovative
f("carscharacteristics").item("3").label(): BMW
f("carscharacteristics").item("3").getType(): OPEN