Hi Patrick,
So you could just add a listener to every question, then enable the "hidden" option to true on each one to accomplish what you want.
So if you stuck this into every question other than the first one asking if they're sick:
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'ANSWER');} "
}
}
Then, you set the newValue to Yes or No depending on which ones you want triggered.
I created a very basic example of this using the details you provided. Only questions 2-5 trigger for Yes and only question 6 will respond to No.
{
"survey" : {
"layout" : "auto",
"showCounts" : false,
"sections" : [ {
"questions" : [{
"name" : "Sick",
"caption" : "Sick",
"shortCaption" : "Sick",
"hidden" : false,
"jsonType" : "string",
"inputType" : "textarea",
"required" : false,
"width" : 800
},{
"name" : "Age",
"caption" : "Age",
"shortCaption" : "Age",
"hidden" : false,
"jsonType" : "int",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'Yes');} "
}
}
}, {
"name" : "Weight",
"caption" : "Weight",
"shortCaption" : "Weight",
"hidden" : false,
"jsonType" : "string",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'Yes');} "
}
}
}, {
"name" : "Gender",
"caption" : "Gender",
"shortCaption" : "Gender",
"hidden" : false,
"jsonType" : "string",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'Yes');} "
}
}
}, {
"name" : "DaysSick",
"caption" : "Days Sick",
"shortCaption" : "Days Sick",
"hidden" : false,
"jsonType" : "string",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'Yes');} "
}
}
}, {
"name" : "MedsTaken",
"caption" : "Meds Taken",
"shortCaption" : "Meds Taken",
"hidden" : false,
"jsonType" : "string",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'Yes');} "
}
}
}, {
"name" : "LastIllness",
"caption" : "Last Illness",
"shortCaption" : "Last Illness",
"hidden" : false,
"jsonType" : "string",
"inputType" : "text",
"required" : false,
"width" : 800,
"hidden": true,
"listeners" : {
"change" : {
"question" : "sick",
"fn" : "function(me, cmp, newValue, oldValue){if (me) me.setVisible(newValue == 'No');} "
}
}
}],
"description" : null,
"header" : true,
"title" : "medical",
"collapsible" : true,
"defaultLabelWidth" : 350
} ]
}
} |