Re: List Boxes
| From: | Andy Woolley | Date: | Fri, 28 Jul 2000 14:38:09 +0000 |
| Subject: | Re: List Boxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8789@lists.php.net to get a copy of this message | ||
You can use any name you like as long as you declare it as an array for
example name='Field[]'
You then need to use the following code in subsequent pages to display the
values like
<?
while (list ($key, $val) = each ($Field))
{
echo $val;
}
?>
This also works the same with multiple text boxes for example:
<form>
<input type=text name=data[field1] value="F1">
<input type=text name=data[field2] value="F2">
<input type=text name=data[field3] value="F3">
<input type=text name=data[field4] value="F4">
</form>
On the submit page
<?
while (list ($key, $val) = each ($data))
{
echo "Value=$val<br>";
}
will display:
Value=F1
Value=F2
Value=F3
Value=F4
Hope this isn't as clear as too much mud
Andy.
?>----- Original Message -----
From: "Krznaric Michael" <mkrznaric@rand.com>
To: "'Andy Woolley'" <andy@reftech.co.uk>
Cc: <php-general@lists.php.net>
Sent: Friday, July 28, 2000 3:15 PM
Subject: RE: [PHP] List Boxes
> Am I to understand in order to retrieve the values from an array, the form
> element name must contain []?
>
> Mike
>
> -----Original Message-----
> From: Andy Woolley [mailto:andy@reftech.co.uk]
> Sent: Friday, July 28, 2000 9:57 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] List Boxes
>
>
> You will need to set up a form variable as an array
>
> When setting up the list box do somethin like this:
>
> <select size=5 multiple name=selector[]>
> <option value='value1'>Value1</option>
> <option value='value2'>Value2</option>
> <option value='value3'>Value3</option>
> <option value='value4'>Value4</option>
> <option value='value5'>Value5</option>
>
>
> To display the selected values after submit do this:
>
> <?
> while (list ($key, $val) = each ($selector))
> {
> echo $val;
> }
> ?>
>
> Hope this helps
>
> Andy.
>
>
> Hi
> I wonder how to get selected items values from List Box (multiple)?
> I need to insert them into db.
>
> Thanks
> --
> Jacek Stachowicz
> jacek@atra.c
om.pl
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>