Re: SELECTINPUT/PHP
| From: | Matt McClanahan | Date: | Sun, 21 May 2000 20:15:08 +0000 |
| Subject: | Re: SELECTINPUT/PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256@lists.php.net to get a copy of this message | ||
On Mon, 22 May 2000, Ayman Mackouly wrote:
> Hi all,
>
> My problem is that I don't know how to retreive the value of SELECT
> inputs, i.e. if "frmName" in about example was of select type, I
> wouldn't be able to use $frmName to retrieve it's value. Anyone knows
> how to do that?
Like all form-related tags, <select> takes a name parameter, which
determines the PHP variable name. The value of that variable is the value
parameter of the <option> that was selected.
For example,
<? if( !$number ) { ?>
<form method="post" action="<? echo $PHP_SELF ?>">
Select a number:<br>
<select name="number">
<option value="1">1
<option value="2">2
<option value="3">3
<input type="submit">
</form>
<? } else { ?>
You selected <? echo $number ?> as your number.<br>
Click here to <a href="<? echo $PHP_SELF ?>">do it again</a>
<? } ?>
Matt