I am trying to pull out the selected value in the second drop down of a drill down menu.
We are trying to pull the selected value set it as a variable then parse only the email out of the selected choice and have it pre-populate a text entry box.
I cant seem to get the selected value out of the drill down though
I have pieced this script together with my limited knowledge of JS.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var ddl1 = document.getElementById("QR~QID1~3");
var Selections = [];
Selections.push (ddl1);
console.log("selection: " + Selections);
var a;
var email = "";
var len = 0;
var b= 0;
for ( a = 0; a < Selections.length; a++ )
{
if (Selections[a] != 0)
{
email = Selections[a].split(" - ")[1];
email = email.trim();
jQuery("#"+this.questionId+" .InputText").val(email).attr("readonly",true);
}
}
});
Page 1 / 1
If you use addOnReady you need to add an event handler (nothing will be selected when the page first loads). A easier option is to use addOnPageSubmit. Something like this should work to get the value of the second drop down:
```
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var dd2val = jQuery("#"+this.questionId+" select").eq(1).val();
... etc ...
});
```
```
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var dd2val = jQuery("#"+this.questionId+" select").eq(1).val();
... etc ...
});
```
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.