Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Inhibit sub-question of multi choice based on other sub questions checked

More
11 years 1 month ago #91653 by ctdh
Hi
I have a 'simple' issue ;) I am struggling with...
A multi choice question:
Q1_SQ1 Choice A
Q2_SQ1 Choice B
Q3_SQ1 Choice C

I would like to be able to disable choice C if either A or B are selected

Can I do this in LS 2.00?

Thanks
Charles
The topic has been locked.
More
11 years 1 month ago #91662 by ctdh
ok I have got this far
Code:
$(document).ready(function() {
 
    $('#answer537386X22X3129SQ3').change(function() {
      if ( $('#answer537386X22X3129SQ3').val() == 'Y' ) {
         $('input[name="537386X22X3129SQ1"]').attr('disabled', 'disabled');
      }
    });
  });

The problem is that the if statement is always being triggered even when I uncheck #answer537386X22X3129SQ3

Any ideas what I need to do??

Thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
11 years 1 month ago #91668 by tpartner
It seems to me that your code is trying to disable choice "A", not choice "C".

If you want to disable "C" when "A" or "B" are selected:
Code:
  $(document).ready(function() {
 
    $('#answer537386X22X3129SQ1, #answer537386X22X3129SQ2').change(function() {
      if ( $(this).attr('checked') == true) {
        $('input[name="537386X22X3129SQ3"]').attr('disabled', 'disabled');
      }
      else {
        $('input[name="537386X22X3129SQ3"]').attr('disabled', '');
      }
    });
  });

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose