Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi

SUJET : Prefill for Array(Numbers)

Prefill for Array(Numbers) il y a 10 mois 3 semaines #100109

  • OlgaN
  • Portrait de OlgaN
  • Hors ligne
  • Fresh Lemon
  • Messages : 1
  • Karma: 0
Hi,

I have two columns and several rows in a question of type Array(Number), each answer drop-down list contains 60 options, which are numbers from 1 to 60. I would like to pre-fill all the drop-down lists so when the page is loaded they already have zeros as chosen options.

I tried two ways but non of them is working:

document.getElementById("#answer{SID}X{GID}X{self.qid}SQ001_SQ001").value = "0";

and

var selectId = 'answer{SID}X{GID}X{self.qid}SQ001_SQ001';
var defaultVal = 'input[id='+selectId+']';
$(defaultVal).val(0);

Could you, please, help me to find out what I am doing wrong and how it should be.
Thanks.
L'administrateur a désactivé l'accès en écriture pour le public.

Prefill for Array(Numbers) il y a 10 mois 3 semaines #100199

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 4118
  • Remerciements reçus 760
  • Karma: 346
Try this:

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		var thisQuestion = $('#question{QID}');
 
		$('select', thisQuestion).each(function(i) {
 
			if($(this).val() == '') {
				$(this).val(0);
			}
		});
	});
</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.
Cet utilisateur a été remercié pour son message par: OlgaN
Modérateurs: ITEd
Temps de génération de la page : 0.128 secondes
Donation Image