Looking for custom coding to remove a blank option at the top of a drop-down question? | XM Community
Skip to main content
Solved

Looking for custom coding to remove a blank option at the top of a drop-down question?

  • May 11, 2018
  • 2 replies
  • 531 views

I sent this question to Qualtrics Support - How do I remove the blank option at the top of a drop-down question? Their response was: "Unfortunately, there isn't a way to remove that "blank field" for the dropdown question very easily."! They suggested adding a default response to the question, but if possible I would like to remove the blank option. They also suggested contacting the Qualtrics community to see if anyone has written the code to do this. If anyone has created the code and would be willing to share, I would greatly appreciate it. Thank you - Patty

Best answer by TomG

Add this to the question's addOnload function: ``` jQuery("#"+this.questionId+" select option:first-child").prop({"disabled":true,"hidden":true}); ```

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • May 11, 2018
Add this to the question's addOnload function: ``` jQuery("#"+this.questionId+" select option:first-child").prop({"disabled":true,"hidden":true}); ```

Forum|alt.badge.img+2
  • May 31, 2022

Hey TomG Michael_Cooksey CamM,
Your answer works perfectly fine when a question with a dropdown list is loaded for the first time. However, if a user selects one of the options from the dropdown and proceeds to the next question and then revisits the previous question to check on the previously selected value then, that case, it will clear the previously selected value by the user and show "Select" option as the value in the dropdown.
Could you please let me know if there is a way to handle this situation as well?