html dropdown/php question

liunx

Guest
Hello;

I have several yes/no dropdowns in a very long form as shown.

<select name=\"Box1\">
<option class=\"text\" value=\"No\">No</option>
<option class=\"text\" value=\"Yes\">Yes</option></select>

<select name=\"Box2\">
<option value=\"No\">No</option>
<option value=\"Yes\">Yes</option></select>

and then of course I parse the POST variables using PhP $_POST['Box1'] etc..

I would like to know if I can just use one array for these values.
something like...

<select name=\"Box[]\">
<option value=\"No\">No</option>
<option value=\"Yes\">Yes</option></select>

<select name=\"Box[]\">
<option value=\"No\">No</option>
<option value=\"Yes\">Yes</option></select>

Is there a way to do this and then retrieve the values with PhP after submit is clicked. I am forced to use separate select containers because of the layout of the form but I want to combine all of the yes/no selections into one array.

thank you,

-cidesign<?php
if (!isset($_POST['submit']))
{
echo '
<form action="" method="POST">
box 1: <select name="box[1]"><option>yes<option>no</select><br>
box 2: <select name="box[2]"><option>yes<option>no</select><br>
box 3: <select name="box[3]"><option>yes<option>no</select><br>
<input type="submit" name="submit" value="submit">
</form>
';
}
else
{
echo 'you selected:<br>';
foreach ($_POST['box'] as $key => $value)
{
echo 'box #' . $key . ': ' . $value . '<br>';
}
}
?>Probably the wrong forum for this, but there you go....
 
Back
Top