Is there a way to make the input for "Randomly insert X choices from the list below" depending on a condition?
Ex: I want X to be 3 when I have 2 companies selected in a previous question, and X to be 5 when i have only one company selected.
Thanks
You can achieve this by creating 3 dummy/hidden questions where,
1. for 1st hidden question add base logic if selected count is 2 and in the randomization add "Randomly insert 3 choices from the list below" as per your requirement and add the below code in JS.
jQuery('input[type="checkbox"]').prop('checked',true)
2. for 2nd hidden question add the base logic if selected count is 1 and in the randomization add "Randomly insert 5 choices from the list below" as per your requirement.
jQuery('input[type="checkbox"]').prop('checked',true)
3. the 3rd question will be your final question where you will just carry forward the answers from the previous main question (suppose Q1) and using the JS punch the selected choices and in your final question (suppose Q2), carry forward the selected choice.
Use the below code in the final hidden question(suppose hfinalQ2).
var prg1_q1 = "${q://QID2/SelectedChoicesRecode}" // 1st hidden question selected recode
var prg2_q1 = "${q://QID3/SelectedChoicesRecode}" // 2nd hidden question selected recode
var arr1=[]
if(prg1_q1.length > 0)
{
arr1 = prg1_q1.split(',')
}
else if(prg2_q1.length > 0)
{
arr1 = prg2_q1.split(',')
}
if(arr1.length >=1)
{
for(var i=0;i
if(arr1[i] !=='')
{
this.setChoiceValueByRecodeValue(Number(arr1[i]),true)
}
}
}
To hide these hidden question, you can use the below code, this code will hide the question when it is not in testing mode.
if (("${e://Field/Q_CHL}" != "preview")){
jQuery('#Wrapper').css('visibility','hidden');
jQuery('#NextButton').click()
}
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.