Re: Return value in Combo Box

From: Date: Tue, 30 Nov 2004 18:45:30 +0000
Subject: Re: Return value in Combo Box
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203166@lists.php.net to get a copy of this message
Ahmed Abdel-Aliem wrote:
can anyone please tell me how to make the choice the user selected in the combo box be selected when the validation page redirects to the form again ?
One way is to do it like this: <select name="foo">
    <option value="1"<?php if ($_POST['foo'] == '1') { echo ' selected="selected"'; } ?>>Foo</option>
    <option value="2"<?php if ($_POST['foo'] == '2') { echo ' selected="selected"'; } ?>>Bar</option>
</select> Another option is to use something like PEAR::HTML_QuickForm, which can do the validation for you: <http://pear.php.net/package/HTML_QuickForm> -- Ben Ramsey Zend Certified Engineer http://benramsey.com --------------------------------------------------- Atlanta PHP - http://www.atlphp.org/ The Southeast's premier PHP community. ---------------------------------------------------

« previous php.general (#203166) next »