Welcome, Guest
Username: Password: Remember me

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

Inhibit sub-question of multi choice based on other sub questions checked 1 year 7 months ago #91653

  • ctdh
  • ctdh's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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 administrator has disabled public write access.

Re: Inhibit sub-question of multi choice based on other sub questions checked 1 year 7 months ago #91662

  • ctdh
  • ctdh's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
ok I have got this far
$(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 administrator has disabled public write access.

Re: Inhibit sub-question of multi choice based on other sub questions checked 1 year 7 months ago #91668

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4139
  • Thank you received: 767
  • Karma: 348
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:
	$(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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.169 seconds
Donation Image