You are here: Re: NEWBIE: sticky select from fields « PHP Programming Language « IT news, forums, messages
Re: NEWBIE: sticky select from fields

Posted by Zoe Blade on 10/28/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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация