Enable/Disable TextEntry or Checkbox depends on Choices in DropDown List in Side by Side Question | XM Community

Enable/Disable TextEntry or Checkbox depends on Choices in DropDown List in Side by Side Question

  • 24 October 2022
  • 3 replies
  • 57 views

Userlevel 1
Badge +2

image.pngFrom the image above. I want to Enable and Disable the other columns whether it is a TextEntry/Dropdown/RadioButton/Checkbox depends on my answer on the 1st column .
For this example using Drop Down List. If I choose "Yes" , other columns will enable but if I choose "No" they will disable.

I tried some JavaScript codes. See here below if you think there is some problem with my code.
image.pngThank you!


3 replies

Userlevel 7
Badge +27

There are a number of problems with your code:

  1. It will only work on the first row

  2. You shouldn't hard code QIDs

  3. The selector used for the change handler is wrong -
    'select:first'
    would work for the first row, but see (1) above.

  4. The if condition is wrong. The value is the id, not the text (i.e., "Yes").
    if(this.value==1)
    would probably work.

  5. You should use
    .prop()
    to set readonly (e.g.,
    .prop("readonly",false);
    )

Userlevel 1
Badge +2

https://community.qualtrics.com/XMcommunity/discussion/comment/51191#Comment_51191It works now but for the 1st row only. What change handler will I be using for the succeeding rows? Thank you

Userlevel 7
Badge +27

https://community.qualtrics.com/XMcommunity/discussion/comment/51198#Comment_51198Ideally, you would loop through the choice rows and adjust your code accordingly.
jQuery("#"+this.questionId+" tr.Choice").each(function(i) {
jQuery(this).find("select:first").change(function(){
...etc...
});
});

Leave a Reply