Welcome, Guest
Username: Password: Remember me

TOPIC: Assigning default values to numerical array in subquestions

Assigning default values to numerical array in subquestions 3 months 1 week ago #111067

  • wstahl09
  • wstahl09's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 1
  • Karma: 0
Hello,

I have a mandatory question that prompts the user to indicate the days and hours since an event, which is saved into a numerical array. I was wondering if there was anyway to set a default value of 0 to both days and hours, and if not how I could go about doing so with javascript.

Thanks!
The administrator has disabled public write access.

Assigning default values to numerical array in subquestions 3 months 1 week ago #111074

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
Are you using an Array (Numbers)(Checkbox) or Array (Texts)(Numbers only) question type?
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.
Last Edit: 3 months 1 week ago by tpartner.
The administrator has disabled public write access.

Assigning default values to numerical array in subquestions 15 hours 8 minutes ago #113976

  • MVT
  • MVT's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 26
  • Karma: 0
Hi,

I tried a tip/workaround find here but...
I've an array of numbers with the checkbox option.
I've added this code (found in the workaround page) :
<script type="text/javascript" charset="utf-8">
   $(document).ready(function() {
       // A function to pre-check a column of an array
       function checkedDefault(qID, column) {
           var checkedCol = column - 1;
           $('#question' + qID + ' table.question tbody tr').each(function(i) {
               if ($('input.checkbox[checked=true]', this).length == 0) {
                   $('input.checkbox:eq(' + checkedCol + ')', this).attr('checked', true);
               }
           });
       }
       // Call the function with a question ID and column number
       checkedDefault(165, 1);
   });
</script>

It works well but...
My question is mandatory. The values (boexe checked) ​​do not appear to be taken into account.

Do I miss something ?
For the moment, I put my question "optional..."

Is it possible (for check boxes) to check on column for all the values in that column ?

Thanks
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.160 seconds
Donation Image