mercredi 25 mars 2020

How to create a form in PHP with checkbox groups and associated select menu for each checkbox

I'm trying to do with PHP and HTML, a form that contains a group of checkboxes and drop-down menus.

I would like that for each chexboxes, there is an associated select menu.

I create checkbox groups dynamically from a MySQL database

For exemple :

Form :

Checkbox 1 (0:off/1:on) - Selectmenu 1 (0:Red, 1:green, 2:blue, 3:yellow)

Checkbox 2 (0:off/1:on) - Selectmenu 2 (0:Red, 1:green, 2:blue, 3:yellow)

Checkbox 3 (0:off/1:on) - Selectmenu 3 (0:Red, 1:green, 2:blue, 3:yellow)

Checkbox 4 (0:off/1:on) - Selectmenu 4 (0:Red, 1:green, 2:blue, 3:yellow)


I managed to create this, and get via POST the checkbox values through an array (input name="check_list[]")

By cons I can not retrieve the values of select menus, and even less to associate them with the corresponding checkbox

Exemple : I would like to get variables like this (via POST):

Checkbox1 and Selectmenu 1 = 0,3  (off and yellow)

Checkbox2 and Selectmenu 2 = 0,2  (off and blue)

Checkbox3 and Selectmenu 3 = 1,1  (off and green)

Checkbox4 and Selectmenu 4 = 0,0  (off and red)

I hope my question is clear enough.

How do I get there?

Thanks




Aucun commentaire:

Enregistrer un commentaire