Pergunta

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.

Foi útil?

Solução

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

Outras dicas

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!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top