Skip to content

Commit

Permalink
Added function to clear text entry box for multiple choice questions
Browse files Browse the repository at this point in the history
  • Loading branch information
tafakkur committed Dec 8, 2020
1 parent 20c1c0d commit d910bb5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions JavaScript Files/Clear Text Entry Box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Qualtrics.SurveyEngine.addOnReady(function(){

const qid = this.questionId;
n_choices = Qualtrics.SurveyEngine.registry[qid].getChoices().length;
// Set this according to where you are placing your text entry box
//This refers to the last choice, -1 to the second last choice etc....
text_choice = n_choices;

this.questionclick = function(event,element){
var selected_choice = element.id.split('~')[2];
if(selected_choice !=text_choice)
{
document.querySelector("#QR\\~" + qid + "\\~" + text_choice + "\\~TEXT").value = "";
}
}

});

0 comments on commit d910bb5

Please sign in to comment.