Developer Documentation Library > Interview templates > UXUI built-in templates > ReplaceItems template
 
ReplaceItems template
Use the ReplaceItems template to specify a position for a question.
For example, you might set up “other specify” as a rating grid subject, and want to provide a place for other text to be entered as well as the rating. To do this, complete the following steps:
1 Set up a block with the grid question and one or more text questions to hold the “other specify” text.
2 Add the uxui_ins_position custom property to the “other specify” category and the uxui_ins_item custom property to the text question.
3 Set the custom properties to a matching number, for example set both properties to 1 for the first “other specify” to include a text box, and set to 2 if a second “other specify” is included.
Format the question that is used as the uxui_ins_item as the question should be displayed where it is inserted.
Special validation might be required. In preceding example, the respondent should enter both an other specify text and a response to the question. This might require a validation function.
Associated properties
uxui_ins_position, uxui_ins_item
Associated uxui_template_props
None
Applies to
Block
Example
Metadata
BlockReplaceItems "" block fields
(
ReplaceItemsQ "{err}Number of students giving the following reasons:"
[
uxui_grid_col_width = "fit-content, 10%",
uxui_template_name = "ReplaceItems"
]
loop
{
Reason1 "Reason 1",
Reason2 "Reason 2",
Reason3 "Reason 3",
Reason4 "Reason 4",
Reason5 "Reason 5",
subother "Other reason (specify)"
{
_05 -
[
uxui_ins_position = "1"
],
_06 -
[
uxui_ins_position = "2"
]
}
} fields -
(
Number ""
style(
Width = "3em"
)
long [0 .. 9999]
codes(
{
NoAnswer "No Answer" NA
} );

);

Other_05 ""
[
uxui_ins_item = "1"
]
style(
Control(
Type = "SingleLineEdit"
)
)
text [0..]
codes(
{
No_Answer "No answer" NA
} );

Other_06 ""
[
uxui_ins_item = "2"
]
style(
Control(
Type = "SingleLineEdit"
)
)
text [0..]
codes(
{
No_Answer "No answer" NA
} );

);
Routing
BlockReplaceItems.ReplaceItemsQ.Label.Inserts["err"] = ""
BlockReplaceItems.Validation.Function = "CheckReplaceItemsBlock"
BlockReplaceItems.Ask()

Function CheckReplaceItemsBlock(Question, IOM, Attempt)
Dim OtherQ, OtherNum

' If the respondent entered text in the other edit box, the
' question must also be answered and vice versa
Set OtherQ = Question.Other_05
Set OtherNum = Question.ReplaceItemsQ[{_05}].Number

If ((Len(OtherQ.Response) > 0 And OtherNum.Response > 0) Or _
(Len(OtherQ.Response) = 0 And OtherNum.Response Is Null)) Then
' This is the scenario that we want
Else
Question.ReplaceItemsQ.Label.Inserts["err"] = "<span class='mrQuestionText'><font color='red'>Enter an other specify text and a response to the question, or clear both.</font></span><br/><br/>"
CheckReplaceItemsBlock = False
Exit Function
End If

Set OtherQ = Question.Other_06
Set OtherNum = Question.ReplaceItemsQ[{_06}].Number

If ((Len(OtherQ.Response) > 0 And OtherNum.Response > 0) Or _
(Len(OtherQ.Response) = 0 And OtherNum.Response Is Null)) Then
' This is the scenario that we want
Else
Question.ReplaceItemsQ.Label.Inserts["err"] = "<span class='mrQuestionText'><font color='red'>Enter an other specify text and a response to the question, or clear both.</font></span><br/><br/>"
CheckReplaceItemsBlock = False
Exit Function
End If

CheckReplaceItemsBlock = True
End Function
See
Interview templates