Default text for dropdown list | XM Community
Skip to main content

I have "Autoadvance on Questions" and "Autoadvance on pages" enabled on my survey. For one of the questions (dropdown list), I'd like to show default text "select one". When i use the code below, the autoadvance gets in the way and submits the survey before user has a chance to actually select an answer. What code should I use?
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
 jQuery("#"+this.questionId+" select").find("option:eq(0)").text("Select one").attr("selected","disabled",true);
});

Thanks.

Try this:
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" select").find("option:eq(0)")
.text("Select one").prop({"disabled":true,"selected":true});
});


This worked. Thank you so much Tom!


Hi, ahmedA TomG Michael_Cooksey,
The above answer works fine. However, if a user selects a value from the dropdown and proceeds to the next question and then revisits the previous question consisting of the dropdown to verify the value which was previously selected then in that case it will show "Select" as a selected value in the dropdown instead of the actual value which was previously selected.
Could you please let me know if there is a solution for this scenario as well?


https://community.qualtrics.com/XMcommunity/discussion/comment/46599#Comment_46599Pipe the selected answer into the JS. If it isn't empty, it has been previously selected.


Thanks for your reply.
I have done something like the below to make it work
var prevSelected = jQuery("#"+this.questionId+" option:selected").length;
if (prevSelected !== 1) {
jQuery("#"+this.questionId+" select").find("option:eq(0)").text("Select one").prop({"disabled":true,"selected":true});
}



Leave a Reply