- Posts: 8
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to make an answer option 'unclickable'?
- hanwerts
- Topic Author
- Offline
- New Member
Less
More
7 years 7 months ago #139578
by hanwerts
How to make an answer option 'unclickable'? was created by hanwerts
Hi,
I have a question on the array option in Lime Survey. As you can see in the attachment, I have an array in the first question with one possible answer option per row (means of transportation in Dutch). In the second question, I want to ask, again per day (!), whether the respondents also make use of other means of transportation. Therefore, I want the option they selected in question 1 to be NOT clickable.
Is that possible. And if yes, how? Thank you!
I have a question on the array option in Lime Survey. As you can see in the attachment, I have an array in the first question with one possible answer option per row (means of transportation in Dutch). In the second question, I want to ask, again per day (!), whether the respondents also make use of other means of transportation. Therefore, I want the option they selected in question 1 to be NOT clickable.
Is that possible. And if yes, how? Thank you!
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 7 months ago #139583
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to make an answer option 'unclickable'?
Are both questions on the same page?
LimeSurvey version?
LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- hanwerts
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
7 years 7 months ago #139585
by hanwerts
Replied by hanwerts on topic How to make an answer option 'unclickable'?
Dear tpartner, thank you!
The questions are indeed on the same page... and version is 2.05+. Hope you can help me
The questions are indeed on the same page... and version is 2.05+. Hope you can help me
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 7 months ago #139590
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to make an answer option 'unclickable'?
Add this script to the source of the first array:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).nextAll('.array-multi-flexi:eq(0)'); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable and un-check the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionRow).prop('disabled', false); $('input.checkbox', nextQuestionCell).prop('checked', false).prop('disabled', true); $('input:hidden', nextQuestionCell).attr('value', ''); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 7 months ago - 7 years 7 months ago #139593
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to make an answer option 'unclickable'?
Oops, forgot to handle things if a respondent returns to the group - use this instead:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify the questions var thisQuestion = $('#question{QID}'); var nextQuestion = $(thisQuestion).nextAll('.array-multi-flexi:eq(0)'); // Initial states // Loop through all clicked radios $('input.radio:checked', thisQuestion).each(function(i) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionCell).prop('disabled', true); }); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { // Find the clicked radio row and column index var thisRow = $(this).closest('tr'); var thisColumn = $(this).closest('td'); var thisRowIndex = $('tr.answers-list', $(this).closest('tbody')).index(thisRow); var thisColumnIndex = $('td.answer-item', $(this).closest('tr')).index(thisColumn); // Disable and un-check the corresponding checkbox in the following question var nextQuestionRow = $('tr.subquestions-list:eq('+thisRowIndex+')', nextQuestion); var nextQuestionCell = $('td.answer-item:eq('+thisColumnIndex+')', nextQuestionRow); $('input.checkbox', nextQuestionRow).prop('disabled', false); $('input.checkbox', nextQuestionCell).prop('checked', false).prop('disabled', true); $('input:hidden', nextQuestionCell).attr('value', ''); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 7 years 7 months ago by tpartner.
The topic has been locked.
- hanwerts
- Topic Author
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
7 years 7 months ago #139703
by hanwerts
Replied by hanwerts on topic How to make an answer option 'unclickable'?
Great! It works :woohoo: . Many, many thanks for your quick and outstanding help!
The topic has been locked.