Repeating Custom Items
A powerful and time-saving feature of custom items is the capability to use them over and over again without having to modify them. If you create a special scale response item with a slider to use in your 50-item questionnaire, you do not want to make 50 versions of it, each with different question wording and response options. Well, maybe you do. If so, no need to read any further. But if you like the idea of 1 file for 50 questions, read on!
Instead of adding the exact question wording to your custom item's HTML code, you can simply say <ml.wording> and MediaLab will automatically substitute the question wording from your questionnaire file. This means, each time you use your custom item in a MediaLab questionnaire, you can enter different question wording the you would for any other normal item. MediaLab will take it and put it into you HTML file for you!
Likewise, instead of using a specific variable name in the HTML form code, you can simply specify <ml.varname>. This means you can now use the same custom item file with many questions in the same questionnaire because each time, MediaLab will substitute the current variable name into the HTML.
You can also substitute other values such as backgrounds, backsounds, backvideos, fonts and colors from the current session and so forth without having to change your item. For all the stuff that MediaLab can substitute into your HTML, see the variable reference table.
Note it is super supremely critical to use the <ml.varname> substitution if you are going to be using the same custom item file over and over again in the same experiment. Otherwise, the posted variable name will be always be the same and so the response will always be written to the same variable in the data file. All of the other substitutions can provide for some handy tricks but they are never necessary.
Substituting Values from the MediaLab Session
In the case of our custom example above, try this modification and save it as myTextBox3.htm
Create three Custom items in your questionnaire and assign them variable names such as ques1, ques2, and ques3. For each, enter the same custom item file: myTextBox3.htm for the file name. As you do this, create a different question wording for each one (e.g., What is your favorite food? What is your favorite animal? What is your favorite movie?). Now run the questionnaire and see what happens. You should find that each time you request it, MediaLab will display it with the appropriate wording from the questionnaire and will save the data from the item using the appropriate variable name.