Hi everyone!
I'm trying to set embedded data so that I pull only the first two characters from drilldown questions using javascript. I'd like to set it on the question itself, using "OnPageSubmit". I found this discussion, but it looks like the code was used on a different question:
https://community.qualtrics.com/XMcommunity/discussion/6601/use-javascript-to-pull-part-of-drill-down-selected-choices-as-embedded-data
I have the javascript code, but am unsure how to pull the actual selection from the drilldown question. For example, for a form field question I've used:
var first = jQuery("#QID2 input[type=text]").eq(0).val();
And for a standard dropdown field, I've used:
var account = jQuery("#QID58 option:selected").text();
I've tried playing with variations of these and haven't come up with anything that works. Any help would be greatly appreciated. Thanks!
Page 1 / 1
After playing around a bit more I managed to answer my own question. For anyone looking in the future, here's what I did:
var month = jQuery("#QID59 option:selected").eq(0).text();
var month = month.substring(0,2);
Qualtrics.SurveyEngine.setEmbeddedData("month", month);
var day = jQuery("#QID59 option:selected").eq(1).text();
var day = day.substring(0,2);
Qualtrics.SurveyEngine.setEmbeddedData("day", day);
So for each set, the first line of code is pulling the first (index 0) or second (index 1) selection from the drilldown. Note that ".text()" pulls the value itself. If you use ".val()" it'll pull the value number.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.