Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Prefill for Array(Numbers)

Prefill for Array(Numbers) 6 Monate 3 Wochen her #100109

  • OlgaN
  • OlgaNs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Prefill for Array(Numbers) 6 Monate 3 Wochen her #100199

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: OlgaN
Moderatoren: ITEd
Ladezeit der Seite: 0.119 Sekunden
Donation Image