Auto punching from numeric text entry to single answer question | XM Community
Skip to main content
If any of you face problem in auto punching from numeric text entry to single answer question. Then answer is below





Qualtrics.SurveyEngine.addOnload(function()

{

var val1= "${q://QID23/ChoiceGroup/AllChoicesTextEntry}";



if(val1<=17)

{

this.setChoiceValue(1, true);

}

if(val1==18 || val1==19)

{

this.setChoiceValue(2, true);

}

if(val1>=20 && val1<=24)

{

this.setChoiceValue(3, true);

}

if(val1>=25 && val1<=29)

{

this.setChoiceValue(4, true);

}

if(val1>=30 && val1<=34)

{

this.setChoiceValue(5, true);

}

if(val1>=35 && val1<=39)

{

this.setChoiceValue(6, true);

}

if(val1>=40 && val1<=44)

{

this.setChoiceValue(7, true);

}

if(val1>=45 && val1<=49)

{

this.setChoiceValue(8, true);

}

if(val1>=50 && val1<=54)

{

this.setChoiceValue(9, true);

}

if(val1>=55 && val1<=59)

{

this.setChoiceValue(10, true);

}

if(val1>=60 && val1<=64)

{

this.setChoiceValue(11, true);

}

if(val1>=65 && val1<=69)

{

this.setChoiceValue(12, true);

}

if(val1>=70)

{

this.setChoiceValue(13, true);

}



//Hide the question from respondent view

//var questionDiv = this.getQuestionContainer();

//questionDiv.style.display = "none";



//this.clickNextButton();



});



Depending on your requirement you can hide the question so that respondent will not see it and you can save your time in recoding during DP stage. In case of any question feel free to let me know.
Moreover, if you want to auto punch Single answer question to single answer question then follow the below code



Qualtrics.SurveyEngine.addOnload(function()

{

var val1= "${q://QID22/SelectedChoicesRecode}";



if(val1==1 || val1==2 || val1==3 || val1==4 || val1==5 || val1==6 || val1==7 || val1==8 || val1==9 || val1==10)

{

this.setChoiceValue(1, true);

}

if(val1==11)

{

this.setChoiceValue(2, true);

}

if(val1==12)

{

this.setChoiceValue(3, true);

}

if(val1==13 || val1==14 || val1==15)

{

this.setChoiceValue(4, true);

}

if(val1==16)

{

this.setChoiceValue(5, true);

}



//Hide the question from respondent view

var questionDiv = this.getQuestionContainer();

questionDiv.style.display = "none";



this.clickNextButton();



});

Leave a Reply