Single Vs. Multiple Variables |
Single vs. Multiple Variables The previous example item collects a single response. The execution of this method is the easiest and is applicable when you have a single value being collected with your custom item. In your MediaLab questionnaire, you name your custom item var01 and in your HTML form, you likewise name your posted variable var01. When the value for var01 is posted, MediaLab will intercept it and save it as the value for var01 in your data files. Done deal. It's a little trickier when you have multiple variables being collected with a single custom item. To deal with this, you have two choices--use a variables parameter or create dummy variables in your experiment. Using a variables Parameter To use the variables parameter, add a v parameter to your Custom item, indicating the number of variables you want to collect, e.g., (v7) would create space for seven variables. The variables will be named after the primary variable name with an underscore and numbers appended. So for example, if the variable name of your Custom item were choice, you could post variables in your HTML form called choice_01, choice_02, ... choice_07. In this example, we ask the participant to list "three good movies". It's very similar to the first example, but here we create three blanks instead of just one. In this case we'll need three variables so we will add the parameter (v3) to our Custom item that we are calling movies. Using the v parameter means that we will reference the variable names by using the primary variable name (movies) along with _01, _02, and _03. To see this sample is action, go to C:\MediaLab\Samples\Sample5 custom items\myTextBox4 - multiple variables An alternative: Dummy Variables Instead of adding a parameter, you can create dummy variables in your experiment that act as placeholders for data with matching variable names. To do so, create an additional Custom item in any questionnaire and give it whatever variable name you like but do not give it a filename. When MediaLab sees that you have listed a Custom item with no file name indicated, it will understand that this item is merely a placeholder for a variable being collected in some other Custom item. When recognized as a placeholder or dummy variable, such items will be skipped during the experimental session. This method provides a nice way of capturing data from questions or surveys where you can not control the variable names that are used in the existing HTML forms. For example, if you look at the source code for a survey on the internet and see that you want to save two variables called age and sex from the many that are being posted, you can include the survey as a Custom item and then add age and sex as two dummy variables in your experiment. In the following example code, the <table> tag along with cell markers are used in order to maintain an orderly look via rows (<tr>) and columns (<td>). <form method="post"> How it looks in a browser: To see this sample is action, go to C:\MediaLab\Samples\Sample5 custom items\myTextBox4 - dummy variables See Also
|