Welcome, Guest
Username: Password: Remember me

TOPIC: Predefined value in Array Number type

Predefined value in Array Number type 1 year 5 months ago #106512

  • pmp
  • pmp's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Hi

I am trying to achieve to get a predfined value on Array Number question type on the load itself.

I tried the following and didnt work on Array Number. But same method works perfectly on Long Text question type.

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

$('#answer864437X180X1278XQ1001_SQ001_A2').val('988');
}
});
</script>

Array column is not showing anything. My expected value 1st row 2nd column is 988

Am i doing something wrong. I am new to this tool and the development. Any help would be apreciated.

Thanks
PMP
Last Edit: 1 year 5 months ago by pmp.
The administrator has disabled public write access.

Predefined value in Array Number type 1 year 5 months ago #106523

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5100
  • Thank you received: 1048
  • Karma: 440
I'm assuming you're using text inputs.

Your selector is wrong and you have a syntax error.

Given:
- survey ID: 864437
- group ID: 180
- question ID: 1001
- y-axis code: SQ001
- x-axis code: A2

The selector should be:
#answer864437X180X1001SQ001_A2

So, the script should be:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		$('#answer864437X180X1001SQ001_A2').val('988');
	});
</script>

Or, even better, test to make sure the question has not been previously answered:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		if($('#answer864437X180X1001SQ001_A2').val() == "") {
			$('#answer864437X180X1001SQ001_A2').val('988');
		}
	});
</script>




.

This message has an attachment image.
Please log in or register to see it.

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.
The administrator has disabled public write access.
The following user(s) said Thank You: pmp

Predefined value in Array Number type 1 year 5 months ago #106575

  • pmp
  • pmp's Avatar
  • Offline
  • Junior Lime
  • Posts: 20
  • Karma: 0
Thanks. That worked.I am not familiar with the script...learning stage :)
Last Edit: 1 year 5 months ago by pmp.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.190 seconds