Jump to content

[SOLVED] Detecting Checkboxes and Option Lists


jayjay76

Recommended Posts

I am trying to figure out how to detect a <Form> check box being checked in a PHP script.  Likewise, I am trying to figure out how to detect which option was chosen in a <option> list of drop-down items in a form.

 

For example, a simplistic form would be something like:

 

 

<Form Method="Post" Action="./php/test.php">

<Center>

  <Table Width='333' border='0' CellPadding='0' CellSpacing='0' bgcolor='#53B5FD'>

        <TR>

            <TD><B>Order Type: </td>

            <TD><div align='right'>

                    <select name='type'>

                    <option value='test1' selected>Test 1</option>

                    <option value='test2'>Test 2</option>

                    <option value='test3'>Test 3</option>

                    </select></div></td>

      </tr>

      <TR>

            <TD><input type='checkbox' name='checktest1' value='On'>Check Me 1</td>

            <TD><input type='checkbox' name='checktest2' value='On'>Check Me 2</td>

            <TD><input type='checkbox' name='checktest3' value='On'>Check Me 3</td>

      </tr>

  </table>

  <Center><input type=submit value='Test'> &nbsp &nbsp &nbsp &nbsp

                  <input type=reset value='Clear'></center>

</form>

 

 

and the associated test.php file . . .

 

 

<?php

$optiontype = $_POST['type'];

$checktype1 = $_POST['checktest1'];

$checktype2 = $_POST['checktest2'];

$checktype3 = $_POST['checktest3'];

Option: $optiontype \n

Check: $                  \n

?>

 

 

 

In this, I am assuming I need to test for "on" or "off" properties of each checktype on the

form, and then only set 'Check' to which ones the person actually checked?

 

This is confusing me greatly :)

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.