Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Reset answers in a table question, using a button and javascript

Reset answers in a table question, using a button and javascript 1 year 3 weeks ago #98452

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
Unfortunately, the second version (add reset button for the whole question) does not work with me.
It works fine for me in citronade. Have you added any other JavaScript? Any JavaScript errors?

Using my layout, you have to scroll to access the reset button.
Yeah, Denis is correct, if using citronade, you need too change the table-layout rule:
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		addReset('{QID}');
 
		function addReset(qID) {
			$('#question'+qID+' table.subquestions-list').css('table-layout', 'auto');
			$('#question'+qID+' table.subquestions-list thead tr').append('<th />');
			$('#question'+qID+' tr.answers-list').append('<td class="buttonCell"><input type="button" value="Reset" class="resetButton" /></td>');
 
			$('#question'+qID+' .resetButton').click(function(e){
				var parentRow = $(this).closest('tr');
				$('input.radio', parentRow).attr('checked', false);
			});
		}
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 3 weeks ago #98600

  • lsorg
  • lsorg's Avatar
Hello,

tpartner
To insert a question rest button below and to the right of the array, add this to the source of the question text:

<script type="text/javascript" charset="utf-8">
$(document).ready(function(){

addReset('{QID}');

function addQuestionReset(qID) {
$('#question'+qID+' table.subquestions-list').after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />');

$('#question'+qID+' .resetQuestionButton').click(function(e){
var parentQuestion = $(this).closest('.array-flexible-row');
$('input.radio', parentQuestion).attr('checked', false);
});
}
});
</script>
The code works very well. But not for array dual scale. Knows everyone how I have to change the code that the reset button works with the array dual scale?

Best regards
lsorg
Last Edit: 1 year 3 weeks ago by lsorg.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 3 weeks ago #98608

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
Knows everyone how I have to change the code that the reset button works with the array dual scale?

Here is a more generic version of the 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>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 3 weeks ago by tpartner.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 1 week ago #98886

  • lsorg
  • lsorg's Avatar
Is it possible to set one reset button for two question which are in the same question group?

I have two dual scales side by side and want only one rest button for them.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 1 week ago #98936

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
Is it possible to set one reset button for two question which are in the same question group?

I have two dual scales side by side and want only one rest button for them.

To reset all radios in all dual-scale-arrays on a page, change this:
$('input.radio', thisQuestion).attr('checked', false);

To this:
$('.array-flexible-duel-scale input.radio').attr('checked', false);
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 1 week ago #98943

  • lsorg
  • lsorg's Avatar
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.
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 1 year 1 week ago #98944

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4117
  • Thank you received: 760
  • Karma: 346
$('#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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 1 week ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: lsorg

Reset answers in a table question, using a button and javascript 10 months 2 weeks ago #100270

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 293
  • Karma: 248
This is a really nice solution. Can/did you add it to the workarounds?!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Reset answers in a table question, using a button and javascript 9 months 4 weeks ago #100967

  • jonsen
  • jonsen's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 73
  • Thank you received: 6
  • Karma: 1
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.147 seconds
Donation Image