- Posts: 13
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
Is there a special reason that you want to use javascript?We are interested in using Javascript in our survey to set the default answers to "0" for an Array (numbers) type of question.
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); var defaultCode = 0; // Loop through the rows $('tr.answers-list', thisQuestion).each(function(i) { var thisRow = $(this); // Set default answer if($('input:radio:checked', thisRow).length == 0) { $('input:radio[value="'+defaultCode+'"]', thisRow).trigger('click'); } }); }); </script>