|
Posted by Zoe Blade on 10/11/75 11:34
> Hi,
> I have a form, with some error checking, that works fine after "submit"
> inserting into DB ---but I have a little problem, I cannot seem to make
> my "select" fields sticky --I have tried several different solutions
> and nothing works.
Something based on this should work:
<html>
<head>
<title>Test form</title>
</head>
<body>
<form method="post">
<select name="session">
<?php
$options = array ('1' => 'Session 1', '2' => 'Session 2', '3' => 'Session 3');
foreach ($options as $value => $name)
{
if (isset($_POST['session']) && $_POST['session'] == $value)
echo " <option value=\"{$value}\" selected=\"1\">{$name}</option>\n";
else
echo " <option value=\"{$value}\">{$name}</option>\n";
}
?>
</select>
<input type="submit" name="submit">
</form>
</body>
</html>
Does that help?
Zoe.
[Back to original message]
|