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.

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.