Jump to content

parsing multiple checkboxes and corresponding text boxes


vampke

Recommended Posts

Hi guys,

 

I am struggling with a form containing multiple checkboxes with corresponding textboxes.

Eg.: there are 5 checkboxes (XS, S, M, L, XL) and 5 textboxes (with values 3,4,5,6,8) that correspond to the checkboxes.

I give all the checkboxes the name 'size[]' and the textboxes the name 'price[]'.

The aim is to have my script set a boolean to true and update the corresponding price if the checkbox is selected.

Unfortunately it does not work this way: checkboxes are only put in the array when they are selected, meaning that if I select only checkbox S and L, the array length is 2 only, but array length price is always 5, so size[1] does not correspond to price[1] necessarily.

 

There probably is a better way to achieve what I need. Could anyone point me in the right direction?

 

edit: BTW the number of items is dynamic: sometimes there will also be XXL or some items will be missing and I also need to set the price for items where the checkbox is not checked.

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.