I know there is code to do this jQuery('input[type="checkbox"]').eq(0).prop('checked',true);but this doesn’t work if the multiple response question is randomised. As it just puts it into the first option that appears rather than option 1.SetChoiceValue doesn’t seem to work either only works for single response. Is there code to reference the actual option code?
I would have thought this would be a common question as hidden questions are common in other platforms in driving a survey. However, I couldn’t find a post on this so just in case anyone wants to know how to do it in Javascript. Would be useful to know how it is done in Qualtrics without Javascript. const QB = "${q://QID9/SelectedChoicesRecode}"; //read answers from multiple response question var result = QB.split(', '); // convert the string answers into an array where the comma and space is the delimiter eg. “1, 2” into [“1”,”2”] if (result.includes("1")) //search in the array for code 1 { //check the first box in a multiple response jQuery('input[type="checkbox"]').eq(0).prop('checked',true); } if (result.includes("2")) ) //search in the array for code 2 { //check the second box in a multiple response jQuery('input[type="checkbox"]').eq(1).prop('checked',true); }
Does anyone know how to access the reference to the javascript library for Qualtrics? For example, this.setChoiceValue shows there must be other functions tied to Qualtrics.SurveyEngine.addOnload. I’m sure there are easier ways to code if only I know what functions are made available or even if there is somewhere, where one learns javascript for Qualtrics. Searching the forums for the exact code that I need can be a lengthy process and even then, I feel some of the code is more complex than I need it to be. Thanks in advance.
I have used Javascript to autofill a question and have checked that it is auto-filling. However, when I go to use the auto-filled question in a display logic for the next question. The display logic is not working.This is the script I used to autofill. Qualtrics.SurveyEngine.addOnload(function(){ var TT1 = "${q://QID26/SelectedChoicesRecode}"; if (TT1 =="2" || TT1=="5" || TT1=="6" || TT1=="7" || TT1=="8" || TT1=="9" || TT1=="11") { for (var i = 0; i < 3; i++) { jQuery('input[type="checkbox"]').eq(i).prop('checked',true) } jQuery("#"+this.questionId).hide(); }});Qualtrics.SurveyEngine.addOnReady(function(){ var TT1 = "${q://QID26/SelectedChoicesRecode}"; if (TT1 =="2" || TT1=="5" || TT1=="6" || TT1=="7" || TT1=="8" || TT1=="9" || TT1=="11") { this.clickNextButton(); }});
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.