Dear All,
I've tried to find a solution on my own, but I'm seeking your input and expertise. As seen in the screenshot I uploaded to Imgur (https://imgur.com/wb4gCFn), when my survey respondents are invited to complete a follow-up survey, each of their medications is first displayed (as well as related dosing and frequency), and one expert (Tom) in this forum helped me implement JavaScript to pre-populate answer choices based on their responses from the first survey that I saved to their contact list entry using embedded data.
Regarding my question and the attached screenshot, if a respondent selects 'Other/Not Listed' from a dropdown (Q7620), a text entry field is pre-populated with the medication name they entered manually the last time they completed the survey. While this works fine, this results in the insertion of a page break when I'd rather have that question remain hidden and the other questions remain on the same screen (i.e., Q7622, Q7623 in the screenshot).
I came across this link https://qualtrics.com/community/discussion/5973/is-there-a-way-to-use-javascript-to-change-the-visibility-of-questions, which I think is along the lines of what I'd like to do (since in-page display logic doesn't let you pull from embedded data).
In the post above, jQuery("#"+this.questionId).hide(); was suggested as a solution, but I'm not sure how to implement this workaround.
Would I add jQuery("#"+this.questionId).hide(); to the question that I want hidden? Relatedly, within this jQuery function, what does "#" get replaced with? Would it be something like this: jQuery("Q7621"+this.questionId).hide();
Thanks in advance!
Page 1 / 1
Hi @NS716 ,
whenever we use `jQuery("#"+this.questionId).hide();` , The question in which this code is inserted that particular question is hidden. We don't need to add anything to hide a specific question.
You can simply write a code to check the embedded data and add if the embedded data has data that you are looking for run the above-mentioned code.
whenever we use `jQuery("#"+this.questionId).hide();` , The question in which this code is inserted that particular question is hidden. We don't need to add anything to hide a specific question.
You can simply write a code to check the embedded data and add if the embedded data has data that you are looking for run the above-mentioned code.
@NiC Thanks for the reply. The latter part of your response is where I'm stuck. Can you provide an example of code that would run jQuery('#'+this.questionId).hide(); based on an embedded data value?
Hey @NS716
Following is the code to hide the question in which this code has been inserted(In your case you can put following code in Q7621)
!
var x = parseInt("${e://Field/Rx1Recode}");
if(x==427){
jQuery("#"+this.questionId).hide();
}
else
{
jQuery("#"+this.questionId).show();
}
You can try the survey where this code is applied -
https://ugamsandbox.ca1.qualtrics.com/jfe/preview/SV_0UMnZQ4U3WcoHYx?Q_SurveyVersionID=current&Q_CHL=preview
Following is the code to hide the question in which this code has been inserted(In your case you can put following code in Q7621)
!
var x = parseInt("${e://Field/Rx1Recode}");
if(x==427){
jQuery("#"+this.questionId).hide();
}
else
{
jQuery("#"+this.questionId).show();
}
You can try the survey where this code is applied -
https://ugamsandbox.ca1.qualtrics.com/jfe/preview/SV_0UMnZQ4U3WcoHYx?Q_SurveyVersionID=current&Q_CHL=preview
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.