I'm using following code to get actual choice for multiple choice question:
var selectedRecode;
this.questionclick = function(event, element) {
if(element.type == "radio")
{ selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices());
alert(selectedRecode);}}
It works fine now, however I'd like to place this code to another question on the same page while the code will be still related to the original question. Therefore I want to put the question object into a variable and replace `this` in code by this variable. Unfortunately I haven't found out how to get the question object. I could probably send my recorde to embedded data each time, but I think there must be some way how to get the object of the previous question...
I've tried following modification of my original code. There was no error, but nothing happened when I clicked on a choice.
var Q = jQuery( "#QID460" );
var selectedRecode;
Q.questionclick = function(event, element) {
if(element.type == "radio")
{ selectedRecode = Q.getChoiceRecodeValue(Q.getSelectedChoices());
alert(selectedRecode);}}
Thanks for any ideas!
Page 1 / 1
Finally, I figured out how to do this without moving the code. I needed to hide or display following question based on the choice which is currently checked.
I used this code:
Qualtrics.SurveyEngine.addOnload(function()
{
var nextQ = document.getElementById("QID1033");
var selectedRecode;
this.questionclick = function(event, element) {
if(element.type == "radio")
{ selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices());
if(selectedRecode == 1) {nextQ.style.display = "block";}
else{nextQ.style.display = "none";}}}
});
I used this code:
Qualtrics.SurveyEngine.addOnload(function()
{
var nextQ = document.getElementById("QID1033");
var selectedRecode;
this.questionclick = function(event, element) {
if(element.type == "radio")
{ selectedRecode = this.getChoiceRecodeValue(this.getSelectedChoices());
if(selectedRecode == 1) {nextQ.style.display = "block";}
else{nextQ.style.display = "none";}}}
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.