Interviewer - Server > Architecture > HTML players > Element names and IDs
 
Element names and IDs
The HTML players generate unique control names and, optionally, IDs for each element on the page. Control names are based on the question, category (response), and navigation names, but may contain only alphanumeric characters and the underscore character (_), and may not start with a number. Each type of element in a questionnaire is identified by a different prefix consisting of an underscore followed by a letter.
The HTML players generate element IDs only if an mrPage tag in the layout template sets the IncludeElementIDs attribute to True. This creates more HTML to be sent to the browser but enables clicking on response texts (at least in some browsers). See Sub-templates for more information.
The rest of this topic describes how the element IDs are generated. You may find this useful if your templates will contain code specific to particular questions, categories, or navigation items.
Questions
The prefix for question control names is _Q so a question called Gender has the control name _QGender. If the question is nested, a full name is constructed using _Q. For example, the control for the BrandA question in the Rating loop would be named _QRating_QBrandA.
If the question name contains an underscore, this becomes a double underscore in the control name the control name for Brand_Preferred is Brand__Preferred. A dot (full stop) in the question name becomes _S in the control name, so the control name for Brand.Preferred is Brand_SPreferred.
Categories
Category control names start with _QParent Question Name_C, for example, _QGender_CMale. If the category is nested, a full name is constructed following the rules for nested questions so, for example, the control for the Good category from the BrandA question in the Rating loop would be named _QRating_QBrandA_CGood.
If the Good category is part of a sublist called Positive, the control name includes both the sublist name (prefixed with _C) and the category name (prefixed with _S) as follows: QRating_QBrandA_CPositive_SGood.
Specified Other
Specified Other category names start with _O. The control for the automatic Other Specify question for the Other category for the BrandA question in the Rating loop would be named _QRating_QBrandA_OOther.
Coded categories
The prefix for categories defined in a codes() block in a response list is _X. For example, the code response DK for the BrandA question in the Rating loop would be named _QRating_QBrandA_XDK.
Navigation buttons
Navigation control names start with _N, so the Next navigation control would be named _NNext.
Element IDs
The HTML players use the same naming strategy for element IDs as it does for element names except that, rather than using the question, category, and navigation names, the HTML Player uses the objects index. Therefore, the ID for category 2 from question 0 has an ID of _Q0_C2.
Loops, compounds, pages and blocks are typically made up of a hierarchy of subquestions. While page and block subquestions are rendered separately down the page, the subquestions for loops and compounds are rendered in a table. IDs for each table must be generated when the IncludeElementIDs attribute is set to True for the mrPage layout template tag (see Sub-templates for details). The IDs for each table take the form Table.TableNumber and the IDs for each cell take the form Cell.x.y.
Summary of element name and ID prefixes
Prefix
Corresponds to
__ (double underscore)
_ (single underscore).
_S
. (full stop/period/dot) This is also the delimiter placed between a category name and a sublist name.
_Q
The start of a question name, for example, _QRating_QBrandA represents the BrandA subquestion within the Rating question.
_C
The start of a category name.
_O
The start of a Specified Other category name.
_X
The start of a category name when the category is defined in a codes() block.
_F
The start of a factored category name.
See also
HTML players