views:

28

answers:

2

Hi guys, i have a bit of logical problem here. I have a catalog of products that have unique ids and options that are displayed to the user through radio buttons. Now my problem is that a user must be able to select different options (from different products) and to submit them to a PHP script that handles this request (via POST). The problem is that the listed products are in one form, and to be able select multiple radio buttons i have to make them with unique names (and to handle the posted choices i have to guess the name of the button). Is there a way to make all the selected choices into array or something, cause otherwise i have to guess the POST-ed field every-time. I need to just pass the id and the options related to him, so i can extract the information from DB.

And one more what is the most convinient way to store selected choices through multiple pages (a.k.a paging - loaded through ajax) - cookies or temp variable.

+1  A: 

Sounds like you should be using Checkboxes rather than Radio buttons - if you want multiple selection

barrylloyd
Yeah that was my first though, but it want be looking that good as the radio buttons
Anonymous
Im not sure why you think it wont look as good. Using Radio Buttons for multiple selection is very inconsistant with the usual user experience. See http://msdn.microsoft.com/en-us/library/aa511488.aspx - 'Is this the right control' section
barrylloyd
Good point, i'll make it with checkboxes. Thanks for the answers though.
Anonymous
A: 

I agree with barrylloid.

then, if you name all your checkboxes something like

product1_select[]

then you should be able to read the values of the selected boxes in the PHP backend using

$_POST['product1_select']

Good luck!

Robbert