More than one question on a page
When a script places more than one question on a page, you can position some or all of the questions one by one, or automatically put them one after the other at a given starting point on the page. The default template uses the second method, so that the questions follow one another down the page. To position the questions individually, use the QuestionName or Index attribute to refer to each question by name or according to its position in the set of questions for the page:
<mrData QuestionName='question_name' [attributes]>
[text]
</mrData>
<mrData Index='number' [attributes]>
[text]
</mrData>
question_name
The question’s name.
number
A number that identifies individual questions on the page. Questions are numbered sequentially from 1 in the order they are named on the page statement.
attributes
Any other attributes that can be used with <mrData> (typically, QuestionElement).
text
Any text of your choice. The interviewing program ignores this text, but it is useful if you want to test the template by opening the .htm file in your browser. In this case, the text appears in the position and with the attributes defined in the file.
Example: Page with two rows of two questions each
For example, if the metadata section contains the statement:
demog "" page (gender, age, mstat, region);
and you want the page to look like this:
you would place the following statements in the template. Either:
<table>
<tr>
<td><mrData QuestionName="gender"/></td>
<td><mrData QuestionName="age"/></td>
</tr>
<tr>
<td><mrData QuestionName="mstat"/></td>
<td><mrData QuestionName="region"/></td>
</tr>
</table>
or:
<table>
<tr>
<td><mrData Index="1"/></td>
<td><mrData Index="2"/></td>
</tr>
<tr>
<td><mrData Index="3"/></td>
<td><mrData Index="4"/></td>
</tr>
</table>
In this example, the additional spacing between the columns has been achieved by setting the width of the question tag for the gender question in the interview script. For more information, see
Horizontal alignment.
Points to bear in mind when using this facility are as follows:
▪QuestionName and Index are interchangeable. In some respects, question names are better than indexes because it is immediately obvious which questions you are referring to. Also, if you insert extra questions, the index numbers will change and the template might no longer refer to the questions you expected. References to question names are not affected in this way. However, using question names ties the template to one set of questions. If you want to use the same layout for all pages with four questions, it is better to use index numbers.
▪Question names take priority over indexes, so if QuestionName and Index appear on the same <mrData> tag, Index is ignored.
▪If two <mrData> tags reference the same question in different ways, the question will be inserted at both locations.
The templates shown earlier have the same number of question names and indexes as there are questions to display, but it is good practice always to include a tag with no attributes at the end of the definition to catch any questions that are not represented by a named or indexed tag. This means that the template will still work even if the page statement names more questions than there are question names or index numbers. The layout will not be perfect, but you will generally pick this up while testing the script. If you do not define an empty tag, any extra questions will not be displayed, and you are less likely to notice this during testing. For example if the template contains:
<mrData QuestionName="age"/>
<mrData QuestionName="mstat"/>
<mrData Index="1"/>
<mrData Index="3"/>
<mrData/>
the rendered page will show age, mstat, gender, mstat, and region in that order.