- Posts: 2
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
7 years 4 months ago #145296
by jbrinchmann
Multiple choice - but two options can turn off all others was created 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.
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11660
- Thank you received: 2742
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.
Replied by holch on topic Multiple choice - but two options can turn off all others
manual.limesurvey.org/Question_type_-_Mu...xclude_all_others.29
Look at "multiple exclusive options".
Look at "multiple exclusive options".
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
7 years 4 months ago #145313
by jbrinchmann
Replied by jbrinchmann on topic Multiple choice - but two options can turn off all others
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.
- davebostockgmail
- Offline
- Elite Member
Less
More
- Posts: 166
- Thank you received: 26
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>
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.