Re: Refreshing form with submittd data
| From: | David Otton | Date: | Thu, 06 Sep 2001 21:17:53 +0000 |
| Subject: | Re: Refreshing form with submittd data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66214@lists.php.net to get a copy of this message | ||
On Thu, 6 Sep 2001 13:46:59 +0100, you wrote:
>I have 3 radio buttons, and I want the one selected by the user to show as
>selected when the page reloads. The form uses POST and points to itself.
>How can I make this better? With a text field I can just do <input
>type=\"text\" name=\"foo\" value=\"$bar\"> but I can't
>figure out how to do
>that sort of thing with radio buttons......
<?
function sel($what) {
global $thumbs;
return($thumbs==$what?'checked':'');
}
?>
<form method="post" action="<?=$PHP_SELF?>">
<p><input type="radio" value="fas" name="thumbs"
<?=sel('fas')?>>
Faster</p>
<p><input type="radio" value="nor" name="thumbs"
<?=sel('nor')?>>
Normal</p>
<p><input type="radio" value="lar" name="thumbs"
<?=sel('lar')?>>
Larger</p>
<p><input type="submit" name="go"
value="Change"></p>
</form>
djo