Welcome, Guest
Username: Password: Remember me

TOPIC: Prefill for Array(Numbers)

Prefill for Array(Numbers) 2 years 2 months ago #100109

  • OlgaN
  • OlgaN's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 1
  • Karma: 0

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";


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

Could you, please, help me to find out what I am doing wrong and how it should be.
The administrator has disabled public write access.

Prefill for Array(Numbers) 2 years 1 month ago #100199

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5261
  • Thank you received: 1097
  • Karma: 457
Try this:

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
		var thisQuestion = $('#question{QID}');
		$('select', thisQuestion).each(function(i) {
			if($(this).val() == '') {
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.
The following user(s) said Thank You: OlgaN
Moderators: ITEd
Time to create page: 0.124 seconds