Can anyone help me with the following JS code? only the first part is working.
what i’m trying to do here (pardon my JS knowledge) is hide QID35 if the answer to QID34 is “Not applicable”
given that QID34 is Matrix Table (likert) type and QID35 is multiple choice with force response and display logic for one of the statement
I don’t want to use display logic as it will create page break and the two questions must be in one page.
Qualtrics.SurveyEngine.addOnload(function() {
// hide next question from start
jQuery("#QID35").hide();
// when current question is clicked
this.questionclick = function(event, element) {
// create variabe with clicked answer and check
var selectedChoice = this.getChoiceRecodeValue()
console.log(selectedChoice)
// show next question if condition is met
if (selectedChoice !== "6") {
jQuery("#QID35").show();}
// in case answer is switched, hide again
// else{
// jQuery("#QID35").hide();
// }
}
});
Thanks in advance!
the user have to click again on any radio button (except NA) so it show the second question
any idea how to fix that?
thanks,
You can use this below updated code to account for the above scenario:
Qualtrics.SurveyEngine.addOnReady(function()
{
if (this.getSelectedAnswerValue(1) !== "6" && this.getSelectedAnswerValue(1) !== null )
{
jQuery("#QID35").show();
}
else {
jQuery("#QID35").hide();
}
this.questionclick = function(event, element) {
if (this.getSelectedAnswerValue(1) !== "6" && this.getSelectedAnswerValue(1) !== null ) { jQuery("#QID35").show();
}
else {
jQuery("#QID35").hide();
}
}
});
Hope this resolves your query!!
Hi
Please use below updated code to accommodate above scenario:
Qualtrics.SurveyEngine.addOnReady(function()
{
if (this.getSelectedAnswerValue(1) !== "6" && this.getSelectedAnswerValue(1) !== null )
{
jQuery("#QID35").show();
}
else {
jQuery("#QID35").hide();
}
this.questionclick = function(event, element) {
if (this.getSelectedAnswerValue(1) !== "6" && this.getSelectedAnswerValue(1) !== null )
{ jQuery("#QID35").show();
}
else {
jQuery("#QID35").hide();
}
}
});
Hope this resolves your query!!
Hi,
Adapt the first part of the code with
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.