I have a slider question (QID64 - "competence of the trainers?") and need to hide and deselect a response based from the question above it. I already have the code to hide but I can't deselect the response.
If the respondent selected "online" then the next question should be hidden and the response should be deleted. Those 2 questions should be on the same page so I cannot use display logic since it is not working with slider questions.
Here's my current code:
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var that=this.questionId;
jQuery("#QID464").hide();
jQuery("#"+ this.questionId+" inputntype='radio']").on('change',function(){
if(jQuery("(id='QR~"+that+"~1']").prop('checked')){
jQuery("#QID464").show();
}else{
jQuery("#QID464").hide();
}
});
});
or is it possible to at least change the star slider response?
In the slider question:
- Find the elements with the class 'ResultsInput' and set their value to '' (empty)
- Find the elements with the class 'Filled' and set their width to 0px
Thank you TomG
I am new to JQuery and I'm trying to do what you've just said. I have already get the value of the star slider but no luck on changing the value to empty. May I please ask for your help with the code?
https://community.qualtrics.com/XMcommunity/discussion/comment/49022#Comment_49022var slider = jQuery("#"+this.questionId).nextAll(".QuestionOuter").first(); //next question
slider.find(".ResultsInput").val("").trigger("change");
slider.find(".Filled").css("width","0px");
TomG I have included the codes as shown below but not sure if it is the right place since it didn't work. The logic is that If I selected "face to face" on the question "The training that you attended took place" then the slider question (competence of the trainers?) should be shown and if I selected "online" then the slider question should hide and reset to empty. Hoping for another help and apologies for bothering you.
Here's the preview link:
https://rochediacx.fra1.qualtrics.com/jfe/preview/previewId/e61cee6e-bee4-487d-bf1e-5ad88e619aee/SV_6X4Qf5JdfHzjwKq?Q_CHL=preview&Q_SurveyVersionID=current
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var that=this.questionId;
jQuery("#QID464").hide();
jQuery("#"+ this.questionId+" inputntype='radio']").on('change',function(){
if(jQuery("(id='QR~"+that+"~1']").prop('checked')){
jQuery("#QID464").show();
//alert("ResultsInput :"+$$('.ResultsInput')(4].value);
}else{
jQuery("#QID464").hide();
var slider = jQuery("#"+this.questionId).nextAll(".QuestionOuter").first(); //next question
slider.find(".ResultsInput").val("");
slider.find(".Filled").css("width","0px");
}
});
});
https://community.qualtrics.com/XMcommunity/discussion/comment/49027#Comment_49027Your initial question wasn't clear. It seemed like there was one slider question with three rows, instead of separate sliders questions with a text/graphic question before them. So, the JS I provided to find the next question doesn't apply. Replace:
var slider = jQuery("#"+this.questionId).nextAll(".QuestionOuter").first(); //next question
with:
var slider = jQuery("#QID464);
Hi TomG Thank you. It is now working on the survey but data for the star slider is still present when I checked the Data & Analysis even the star slider value was set to empty. Is there anything else that I missed?
https://community.qualtrics.com/XMcommunity/discussion/comment/49054#Comment_49054Are you sure? When I tried it and piped the answer on the next page it was blank.
TomG - I'm checking the Data & Analysis part. The response from the star rating (QID464) should be empty since I have selected code 2 (online) in QID475.
Here's the exact script that I am using
https://community.qualtrics.com/XMcommunity/discussion/comment/49116#Comment_49116Add .trigger("change") to the line that sets the ResultsInput value. I've added it to the accepted answer above.
Thank you so much TomG. It is now working as expected.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.