Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

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

Reset answers in a table question, using a button and javascript 8 Monate 3 Wochen her #98452

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 2 Wochen her #98600

  • lsorg
  • lsorgs 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
Letzte Änderung: 8 Monate 2 Wochen her von lsorg.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 2 Wochen her #98608

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
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.
Letzte Änderung: 8 Monate 2 Wochen her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 1 Woche her #98886

  • lsorg
  • lsorgs 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 1 Woche her #98936

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 1 Woche her #98943

  • lsorg
  • lsorgs 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 8 Monate 1 Woche her #98944

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
$('#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.
Letzte Änderung: 8 Monate 1 Woche her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: lsorg

Reset answers in a table question, using a button and javascript 6 Monate 2 Wochen her #100270

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5278
  • Dank erhalten: 289
  • Karma: 246
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'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Reset answers in a table question, using a button and javascript 5 Monate 3 Wochen her #100967

  • jonsen
  • jonsens Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 61
  • Dank erhalten: 2
  • Karma: 0
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.168 Sekunden
Donation Image