- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Predefined value in Array Number type
- pmp
- Topic Author
- Offline
- New Member
Less
More
10 years 1 month ago - 10 years 1 month ago #106512
by pmp
Predefined value in Array Number type was created by pmp
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
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: 10 years 1 month ago by pmp.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
10 years 1 month ago #106523
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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:
So, the script should be:
Or, even better, test to make sure the question has not been previously answered:
.
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:
Code:
#answer864437X180X1001SQ001_A2
So, the script should be:
Code:
<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:
Code:
<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
The topic has been locked.
- pmp
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
10 years 1 month ago - 10 years 1 month ago #106575
by pmp
Replied by pmp on topic Predefined value in Array Number type
Thanks. That worked.I am not familiar with the script...learning stage
Last edit: 10 years 1 month ago by pmp.
The topic has been locked.