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
https://forums.phpfreaks.com/topic/249266-checkbox-arrays-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.