Jump to content

Checkbox Arrays! HELP!


Chud37

Recommended Posts

Hello,

 

I have to write a booking form and in my form I have a jQuery function that allows to add as many extra people as you like.  For each person, they have to select which days they want to be there for, IE, friday, saturday, sunday or monday.

 

The checkboxes are as such:

<input type="checkbox" id="a_friday" name="adultFri[]" class="hideMe">
<input type="checkbox" id="a_friday" name="adultSat[]" class="hideMe">
<input type="checkbox" id="a_friday" name="adultSun[]" class="hideMe">
<input type="checkbox" id="a_friday" name="adultMon[]" class="hideMe">

 

Which is fine.  However, because some of the checkboxes will not be selected, the arrays dont line up when I recieve them.  For example, if adult #1 checks friday and saturday, and adult #2 checks sunday and monday, I end up with this:

 

adultFri[0] = on

adultSat[0] = on

adultSun[0] = on

adultMon[0] = on

 

The adultSun and adultMon should both be at point 1.  This is because If the checkbox isnt checked, it doesnt get passed through.  Does anyone have a solution to this?

 

Please help! Thanks.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.