Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Predefined value in Array Number type

More
9 years 11 months ago - 9 years 11 months ago #106512 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
Last edit: 9 years 11 months ago by pmp.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #106523 by tpartner
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:
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.
The following user(s) said Thank You: pmp
The topic has been locked.
More
9 years 11 months ago - 9 years 11 months 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: 9 years 11 months ago by pmp.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose