radio buttons and checkbox values in php

              <tr>
                 <td><input type = \"checkbox\" name = \"edtROOMSERV\" value = \"".$_REQUEST["edtROOMSERV"]."\">Room Service</td>
              </tr>
              <tr>
                 <td>Are You Vegetarian?</td>
              </tr>
              <tr>
                 <td><input type = \"radio\" name = \"edtVEG\" value = \"".$_REQUEST["edtVEG"]."\">Yes</td>
              </tr>
              <tr>
                 <td><input type = \"radio\" name = \"edtVEG\" value = \"".$_REQUEST["edtVEG"]."\">No</td>
              </tr>
              <tr>
                <td>Which Meals Would You Like?</td>
              </tr>
              <tr>
                 <td><input type = \"checkbox\" name = \"edtBFAST\" value = \"".$_REQUEST["edtBFAST"]."\">Breakfast</td>
              </tr>
              <tr>
                 <td><input type = \"checkbox\" name = \"edtLUNCH\" value = \"".$_REQUEST["edtLUNCH"]."\">Lunch</td>
              </tr>
              <tr>
                 <td><input type = \"checkbox\" name = \"edtSUPPER\" value = \"".$_REQUEST["edtSUPPER"]."\">Supper</td>
              </tr>
              <tr>
                  <td colspan=\"2\" style=\"text-align:right\"><input type=\"button\" value=\"<<Prev\" onclick=\"setregid(1);\"><input type=\"button\" value=\"Next>>\" onclick=\"setregid(3);\"></td>
                </tr>
              </table>"

this is the code im working on, my problem now is getting the values of the check box back later in my code…how do i assign values to the checkbox so i can call it back?

Do You Need Accomodation?
Yes
No

You’ll want to store the values into an array and then use a loop function to recall. I believe you would name all the checkboxes for one set the same thing. So:

<tr> <td><input type = \"checkbox\" name = \"edtmeal[]\" value = \"".$_REQUEST["edtBFAST"]."\">Breakfast</td> </tr> <tr> <td><input type = \"checkbox\" name = \"edtmeal[]\" value = \"".$_REQUEST["edtLUNCH"]."\">Lunch</td> </tr> <tr> <td><input type = \"checkbox\" name = \"edtmeal[]\" value = \"".$_REQUEST["edtSUPPER"]."\">Supper</td> </tr>

I’m still trying to work out a checkbox issue I’m having right now, so I’m afraid I can’t help with the rest. For example, reconciling your $_REQUEST[] fields…Perhaps someone else could help with that?

I’ve been able to get my checkbox problem to work with the following solution I found on the boards here with a search:

[php]if(is_array($_POST[“element_16”])) $exp1b = implode(’, ',$_POST[“element_16”]);
[/php]

You can similarly use an if loop to recall the checkbox array. My example is being used in an e-mail form, but maybe it’ll give you an idea. (I figure something’s better than nothing)

Sponsor our Newsletter | Privacy Policy | Terms of Service