Automatically Answer a Drill Down Question With Only One Choice | XM Community
Skip to main content

Hello!
I am trying to write a JS code which automatically selects the only choice of my fourth drill down question (treatment status, as shown in the picture below), but I have not been successful.
image.pngI have found this code (https://gist.github.com/marketinview/8310ba82acde38be62f007095bbe0278#file-answeronechoicemc-js-L2) that works for multiple choice questions, but I am not sure how it should be adapted to a drill down question.
Could anyone help with this?

Thanks so much!

Ieda

Without understanding the full setup but perhaps you can make the "treatment status" a separate row from the others, put a display logic on it depending on the choices made in the drop downs and then have a default value set on it so it's checked when it appears?
As a person with absolutely no skills in JavaScript I need to find alternatives, haha.

Have a great day!
-Mattias


Hi, if you still need, the below JavaScript will automatically select the only option of the 4th drilldown row when a selection is made in the 3rd drilldown row:

var qid = this.questionId;
var sel3 = document.getElementById('QR~'+qid+'~3');
var sel4 = document.getElementById('QR~'+qid+'~4');

jQuery(sel3).on('change', function() {
sel4.optionss1].selected = true;
});

 


Leave a Reply