Predefined value in Array Number type

More
3 years 4 months ago - 3 years 4 months ago #106512 by pmp
pmp created the topic: Predefined value in Array Number type
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: 3 years 4 months ago by pmp.

Please Log in to join the conversation.

More
3 years 4 months ago #106523 by tpartner
tpartner replied the topic: Predefined value in Array Number type
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>




.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: pmp

Please Log in to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #106575 by pmp
pmp replied the topic: Predefined value in Array Number type
Thanks. That worked.I am not familiar with the script...learning stage :)
Last Edit: 3 years 4 months ago by pmp.

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now