Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi
  • Page :
  • 1
  • 2

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

Reset answers in a table question, using a button and javascript il y a 1 an 6 jours #98452

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4071
  • Remerciements reçus 748
  • Karma: 341
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.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 1 an 1 jour #98600

  • lsorg
  • Portrait de lsorg
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
Dernière édition: il y a 1 an 1 jour par lsorg.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 1 an 1 jour #98608

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4071
  • Remerciements reçus 748
  • Karma: 341
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.
Dernière édition: il y a 1 an 1 jour par tpartner.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 11 mois 3 semaines #98886

  • lsorg
  • Portrait de lsorg
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.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 11 mois 3 semaines #98936

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4071
  • Remerciements reçus 748
  • Karma: 341
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.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 11 mois 3 semaines #98943

  • lsorg
  • Portrait de lsorg
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.
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 11 mois 3 semaines #98944

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4071
  • Remerciements reçus 748
  • Karma: 341
$('#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.
Dernière édition: il y a 11 mois 3 semaines par tpartner.
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: lsorg

Reset answers in a table question, using a button and javascript il y a 9 mois 4 semaines #100270

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5301
  • Remerciements reçus 291
  • Karma: 247
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'"
L'administrateur a désactivé l'accès en écriture pour le public.

Reset answers in a table question, using a button and javascript il y a 9 mois 1 semaine #100967

  • jonsen
  • Portrait de jonsen
  • Hors ligne
  • Senior Lime
  • Messages : 71
  • Remerciements reçus 6
  • Karma: 1
L'administrateur a désactivé l'accès en écriture pour le public.
  • Page :
  • 1
  • 2
Modérateurs: ITEd
Temps de génération de la page : 0.170 secondes
Donation Image