- Posts: 10109
- Thank you received: 3595
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Reset answers in a table question, using a button and javascript
- lsorg
- Visitor
10 years 8 months ago #98943
by lsorg
Replied by lsorg on topic Reset answers in a table question, using a button and javascript
Thanks for the code, but with .array-flexible-dual-scale it resets each dual scale on the page an I only want that it reset two specifc scales with ID 775 and 1066.
But I will keep trying.
But I will keep trying.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
10 years 8 months ago - 10 years 8 months ago #98944
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 Reset answers in a table question, using a button and javascript
Code:
$('#question775 input.radio, #question1066 input.radio').attr('checked', false);
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 8 months ago by tpartner.
The following user(s) said Thank You: lsorg
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
10 years 6 months ago #100270
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Reset answers in a table question, using a button and javascript
This is a really nice solution. Can/did you add it to the workarounds?!
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- jonsen
- Offline
- Junior Member
Less
More
- Posts: 26
- Thank you received: 3
10 years 6 months ago #100967
by jonsen
Replied by jonsen on topic Reset answers in a table question, using a button and javascript
I added a feature request at:
bugs.limesurvey.org/view.php?id=8310
The topic has been locked.
- Maverick87Shaka
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 11 months ago #136025
by Maverick87Shaka
Hi to all,
I know it's a really old post, but i really need the same function in my survey today.
Anyone can help me to adapt the code to the version: Version 2.50+ Build 160504 .
I try the "simple alert" code to test if javascript is working and i have the pop-up with the alert message like suggested in the limesurvey guide.
Unfortunate the code for my array dual scale question doesn't work:
Where 19 is the ID of my question test.
Replied by Maverick87Shaka on topic Reset answers in a table question, using a button and javascript
tpartner wrote: Here is a more generic version of the code:
Code:<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('{QID}'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestions-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).attr('checked', false); }); } }); </script>
Hi to all,
I know it's a really old post, but i really need the same function in my survey today.
Anyone can help me to adapt the code to the version: Version 2.50+ Build 160504 .
I try the "simple alert" code to test if javascript is working and i have the pop-up with the alert message like suggested in the limesurvey guide.
Unfortunate the code for my array dual scale question doesn't work:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ addReset('19'); function addQuestionReset(qID) { var thisQuestion = $('#question'+qID+''); $('table.subquestions-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />'); $('#question'+qID+' .resetQuestionButton').click(function(e){ $('input.radio', thisQuestion).attr('checked', false); }); } }); </script>
Where 19 is the ID of my question test.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
7 years 11 months ago #136051
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 Reset answers in a table question, using a button and javascript
Try this (no need to modify {QID}):
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.radio', thisQuestion).prop('checked', false); }); } }); </script>
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: Maverick87Shaka
The topic has been locked.
- Maverick87Shaka
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 11 months ago #136073
by Maverick87Shaka
Yes! This is finally working on the new version, thanks so much!
Replied by Maverick87Shaka on topic Reset answers in a table question, using a button and javascript
tpartner wrote: Try this (no need to modify {QID}):
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.radio', thisQuestion).prop('checked', false); }); } }); </script>
Yes! This is finally working on the new version, thanks so much!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
7 years 11 months ago #136075
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 Reset answers in a table question, using a button and javascript
This is nothing, wait until you see your other post
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Maverick87Shaka
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
7 years 11 months ago - 7 years 11 months ago #136137
by Maverick87Shaka
Replied by Maverick87Shaka on topic Reset answers in a table question, using a button and javascript
Using reset button in the array works very well.
We have just a little "issues" made by the logic of my survey.
Currently I'm using the array question type, with the option to to force the user to select only 2 sub-question of 3 available ( Minimum/Maximum answers: 2 )
When you enable this feature, under the question title you have a "TIPS" that make a remind to the user to select 2 answers. This tips are nice and dynamic, that becomes green colored when the user responds correctly at the array.
Using Reset question as is coded right now, the radio button selection was deleted but the TIPS wasn't reset too ( remains green even no selection is made ). There is a way to reset also tips logic of that question at the same time?
We have just a little "issues" made by the logic of my survey.
Currently I'm using the array question type, with the option to to force the user to select only 2 sub-question of 3 available ( Minimum/Maximum answers: 2 )
When you enable this feature, under the question title you have a "TIPS" that make a remind to the user to select 2 answers. This tips are nice and dynamic, that becomes green colored when the user responds correctly at the array.
Using Reset question as is coded right now, the radio button selection was deleted but the TIPS wasn't reset too ( remains green even no selection is made ). There is a way to reset also tips logic of that question at the same time?
Last edit: 7 years 11 months ago by Maverick87Shaka.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
7 years 11 months ago #136143
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 Reset answers in a table question, using a button and javascript
This should do the trick:
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" />'); $('.resetQuestionButton', thisQuestion).click(function(e){ $('input.radio', thisQuestion).prop('disabled', false); $('input.radio:checked', thisQuestion).each(function(i) { $(this).prop('checked', false); checkconditions('', this.name, this.type); }); }); } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jsibley
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 0
7 years 2 months ago - 7 years 2 months ago #148889
by jsibley
Replied by jsibley on topic Reset answers in a table question, using a button and javascript
This seems really helpful, but what if I would like to reset the answers in an array to "no answer"? In this version, even that is deselected.
I'm using version 2.5, btw.
Many thanks.
I'm using version 2.5, btw.
Many thanks.
Last edit: 7 years 2 months ago by jsibley.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
7 years 2 months ago #148891
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 Reset answers in a table question, using a button and javascript
This should work with or without "No answer":
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" />'); $('.resetQuestionButton', thisQuestion).click(function(e){ if($('input.radio[value=""]', thisQuestion).length > 0) { $('input.radio[value=""]', thisQuestion).trigger('click'); } else { $('input.radio', thisQuestion).prop('disabled', false).prop('checked', false); } $('input.radio', thisQuestion).each(function(i) { checkconditions(this.value, this.name, this.type); }); }); } }); </script>
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: jsibley
The topic has been locked.