I’m writing a php form and I can’t get the drop down boxes to stick as in when I fill in my details but don’t click something it will keep everything else filled but that one part that wasn’t filled out. I can do it for the input text and radio buttons but I can’t get it done for drop downs
[code]
@import url(stickyTextInput.css); [/code][php]<?php
if(isset($_REQUEST["left"]))
{
process_form();
}
else
{
display_form_page('');
}
?>
<?php
function display_form_page($error)
{
$self =$_SERVER['PHP_SELF'];
$first_name = isset($_REQUEST['name']) ? $_REQUEST['name']:'';
$last_name = isset($_REQUEST['lastname']) ? $_REQUEST['lastname']:'';
$age = isset($_REQUEST['age']) ? $_REQUEST['age']:'';
$gender = isset($_REQUEST['gender']) ? $_REQUEST['gender']:'';
$color = isset($_REQUEST['color']) ? $_REQUEST['color']: '';
$food = isset($_REQUEST['food']) ? $_REQUEST['food']:'';
?>
[/php]
[code]
Forms Sticky input @import url(stickyTextInput.css); .error { color:#ff0000 } [/code][php]<?php
if($error)
{
echo “
$error
\n”;}
?>
[/php]
[code]" method = "post">
Forms-Sticky Input
First Name: ">Last Name:
">
Age:
Gender
<input type=“radio” name=“gender” value=“male” <?php check($gender, "male")?>>Male
<input type=“radio” name=“gender” value=“female” <?php check ($gender, "female")?>>Female
Select favourite Colour
<option <?php dropdown($color, "Red")?>>Red
<option <?php dropdown($color, "Blue")?>>Blue
<option <?php dropdown($color, "Green")?>>Green
<option <?php dropdown($color, "Pink")?>>Pink
Food
<input type=“checkbox” name=“food[]” value=“beans” <?php checkbox($food, "beans")?>>Beans
<input type=“checkbox” name=“food[]” value=“crisps” <?php checkbox($food, "crisps")?>>Crisps
<input type=“checkbox” name=“food[]” value=“lemons” <?php checkbox($food, "lemons")?>>Lemons
[php]<?php
}
?>
"; } if (!preg_match($reg_exp, $last_name)) { $error .= "Last Name is invalid (letters, hyphens, ', only)
"; } if (!is_numeric($age)) { $error .= "Age is invalid (numbers only)
"; } if (strlen($gender) == 0) { $error .= "Select Male/Female
"; } if (strlen($color) == 0) { $error .= "Select one color
"; } if (! is_array($food)) { $error .= "You must select one food
"; } return $error; } ?> <?php function display_output_page() { $first_name = trim($_REQUEST['name']); $last_name = trim($_REQUEST['lastname']); $age = trim($_REQUEST['age']); $gender = isset($_REQUEST['gender']) ? $_REQUEST['gender']:''; $color = isset($_REQUEST['color']) ? $_REQUEST['color']:''; $food = isset($_REQUEST['food']) ? $_REQUEST['food']:''; ?> Form Results
Form Results
<?php echo " First Name: $first_name\n"; echo " Last Name: $last_name
\n"; echo " Age: $age
\n"; echo " Gender: $gender
\n"; echo " Favourite Color: $color
\n"; echo "
- ";
if (is_array($food))
{
echo "Favourite Food is:";
foreach($food as $selection)
{
echo "
- $selection "; } } echo "
[code]
[/code][php]<?php
}
?>
[/php]
So I hope that makes sense so I have it where if I input my name, age, and what my gender is and also my favourite food it does it no problem like say if I don’t put in a last name it goes back to the form but everything is still but colour