How to extract the text value(s) selected from a drill-down in JS? | XM Community
Skip to main content

I'm trying to capture the actual text values of the selected options of in a drill-down question.
Qualtrics.SurveyEngine.addOnPageSubmit(function() 
{
    var location = jQuery("#"+this.questionId+" select").eq(0).val();
}

location
has an integer value of the position in the list. Calling
jQuery("#"+this.questionId+" select").eq(0).text()
returns the full list of all options as a string.
How do I only get the one item that was select as the text of the option selected?
Thank you!

Try this:
jQuery('#"+this.questionId+"').find(":selected").text()


I agree with grahulp5 save for one change: I don't think that jQuery is gonna work, something looks funny about the apostrophes and quotes. If I may suggest a small amend, here's what I'd use.
jQuery('#' + this.questionId).find(":selected").text()
This returns the selected dropdown value as a string (null when page loads, string value upon reload/revisiting). Please drop a comment here if this doesn't give you exactly what you're looking for.


Leave a Reply