Welcome to the LimeSurvey Community Forum

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

Multiple choice - but two options can turn off all others

  • jbrinchmann
  • jbrinchmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 4 months ago #145296 by jbrinchmann
Hi,

I am trying to put together my first survey, and overall it is satisfyingly straightforward. However I am running into one problem:

I have a question where I have a multiple choice box with five options. Three of these should be non-excluding, but the two final options should exclude all others. I presume I need Javascript for this and I tried the workaround for array questions but could not manage to modify this correctly. Any pointers welcome!

I am using a very slightly modified version of news_paper and LimeSurvey 2.52.

Thanks!
Jarle.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago #145297 by holch

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: tpartner
The topic has been locked.
  • jbrinchmann
  • jbrinchmann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 4 months ago #145313 by jbrinchmann
Thanks very much! That works - not quite in the slickest way (I would have liked to have the irrelevant options deselected, not grayed out), but it does what I need, which is sufficient.
The topic has been locked.
More
7 years 4 months ago #146007 by davebostockgmail
Replied by davebostockgmail on topic Multiple choice - but two options can turn off all others
Hi,
I had the same issue in that the only exclusive option in a multiple was the fifth answer, however if you selected option one or option two then you could not select option 3, and if option 3 was selected then you could not select option one or two.

Took me a while but this is the jquery script that seemed to do the trick for me.

Note: I had to use a trigger click event to make the page believe that the option was being clicked as setting the property of the checkbox to checked, true and checked, false did not seem to behave as expected.

<script type="text/javascript">
$(document).ready(function(){
$('#answer963763X273X89293').click(function(){
if($(this).is(":checked") && $('#answer963763X273X89291').is(":checked")){
$('#answer963763X273X89291').trigger('click');
}
if($(this).is(":checked") && $('#answer963763X273X89292').is(":checked")){
$('#answer963763X273X89292').trigger('click');
}
});
$('#answer963763X273X89291').click(function(){
if($(this).is(":checked") && $('#answer963763X273X89293').is(":checked")){
$('#answer963763X273X89293').trigger('click');
}
});

$('#answer963763X273X89292').click(function(){
if($(this).is(":checked") && $('#answer963763X273X89293').is(":checked")){
$('#answer963763X273X89293').trigger('click');
}
});
});
</script>
The following user(s) said Thank You: jbrinchmann
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose