vampke Posted April 4, 2011 Share Posted April 4, 2011 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, 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. Quote Link to comment https://forums.phpfreaks.com/topic/232649-parsing-multiple-checkboxes-and-corresponding-text-boxes/ Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 This belongs in "PHP Coding Help", NOT "Server Administration". Moving. Quote Link to comment https://forums.phpfreaks.com/topic/232649-parsing-multiple-checkboxes-and-corresponding-text-boxes/#findComment-1196673 Share on other sites More sharing options...
dcro2 Posted April 4, 2011 Share Posted April 4, 2011 You could set the value of the checkboxes to their respective number and then use the values in the array you get to set the prices. Quote Link to comment https://forums.phpfreaks.com/topic/232649-parsing-multiple-checkboxes-and-corresponding-text-boxes/#findComment-1196683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.