Hiding drilldown answers based on embedded data | XM Community
Skip to main content

I am designing a survey to be used as an intake form with preferences and selections from a respondent. We have decided to use the drill down question type for its clean design and user interface. We prefer not to have a second version of the question that has different responses and though JS could be the solution.

I want to hide/remove one option based on embedded data; the option value is 40 (from the inspector view). So far, I have been able to use JS to hide the first drill down box but not just the option. A few of my attempts have included selecting from the n-th child and then .hide() or .remove() which selects the option before hiding the entire box. 

Based on other posts, I believe my answer may lie on the old Qualtrics Community site that is no longer accessible (https://www.qualtrics.com/community/discussion/comment/15688#Comment_15688).

 

Here is what I have attempted in code:

if("${e://Field/EmbeddedData}"=="123") { 
jQuery("#"+this.questionId+" select option:nth-child(7)").remove()};

Appears to have no impact

if("${e://Field/EmbeddedData}"=="123") { 
jQuery("#"+this.questionId+ "\\~1"+" option:nth-child(7)").hide()};

Appears to have no impact 

if("${e://Field/EmbeddedData}"=="123") { 
jQuery("#"+this.questionId+" select ").eq("0").val("40").hide()};

Selects option 40 in the first drop down, then hides the response box; still able to select the responses associated with option 40’s group in the second drill down.

if("${e://Field/EmbeddedData}"=="123") { 
jQuery("#"+this.questionId+" select ").eq("0").val("40").remove()};

Removes the response box, cannot select responses in the second drill down.

 

Is the issue that JS does not know which dropdown I am referencing? Is what I am attempting to do even possible?

Guidance is much appreciated. 

Try to use the below code. Also, make sure to put all code in ‘addOnReady’ function.

jQuery("#"+this.questionId+" select ").eq("0").find("optiontvalue='40']").remove();

 


Try to use the below code. Also, make sure to put all code in ‘addOnReady’ function.

jQuery("#"+this.questionId+" select ").eq("0").find("optiontvalue='40']").remove();

 

I added the curly bracket before the semi-colon and this worked. Thank you!


Leave a Reply