- Posts: 19
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Deselect click in Array
- simatz
- Topic Author
- Offline
- New Member
Less
More
4 years 1 month ago - 4 years 1 month ago #194847
by simatz
Deselect click in Array was created by simatz
Hello, my array is not mandatory.
It means that I give the choice not to answer a certain subquestion.
But I got a problem and could not find in the manual how to solve it.
If I click on a certain subquestion a specific answer and than i regret and I don't want to answer this sub question at all I can not deselect my click.
What can I do?
Thanks
Sima
It means that I give the choice not to answer a certain subquestion.
But I got a problem and could not find in the manual how to solve it.
If I click on a certain subquestion a specific answer and than i regret and I don't want to answer this sub question at all I can not deselect my click.
What can I do?
Thanks
Sima
Last edit: 4 years 1 month ago by simatz.
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 1 month ago #194854
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 Deselect click in Array
By definition, you cannot de-select a radio input without selecting another associated radio.
The simple solution is to add a "No answer" option in the array answers
The simple solution is to add a "No answer" option in the array answers
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: simatz
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 years 1 month ago #194855
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Deselect click in Array
This is the behaviour of this type (therefore they are called "radio buttons").
Well, I adapted an old script of tpartner.
www.limesurvey.org/forum/can-i-do-this-w...utton-and-javascript
This resets the whole array. Maybe tpartner will provide something the works only for one row.
After clicking "Reset"
Joffm
Well, I adapted an old script of tpartner.
www.limesurvey.org/forum/can-i-do-this-w...utton-and-javascript
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addQuestionReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestion-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input[type="radio"]', thisQuestion).prop('checked', false); }); } }); </script>
This resets the whole array. Maybe tpartner will provide something the works only for one row.
After clicking "Reset"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: simatz
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 1 month ago #194920
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 Deselect click in Array
Here is a quick solution to insert a reset button for each row:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Insert the reset buttons $('table.subquestion-list .answertext', thisQuestion).append('<div><button type="button" class="btn btn-sm btn-primary inserted-reset">Reset row</button></div>'); // Listener on the reset buttons $('.inserted-reset', thisQuestion).on('click', function(e) { var thisRow = $(this).closest('tr'); $('input:radio', thisRow).prop('checked', false); checkconditions('', $('input:radio:eq(0)', thisRow).attr('name'), 'radio'); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Joffm, simatz
The topic has been locked.