Re: HTML_Quickform question
| From: | Stefan Ohrmann | Date: | Tue, 08 Jun 2004 21:58:05 +0000 |
| Subject: | Re: HTML_Quickform question | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13019@lists.php.net to get a copy of this message | ||
Hello,
Am 08.06.2004 22:27 schrieb John Lawson:
> I am trying to populate a list box with data from a database. I am using
> the following syntax, where select_data is an array containing descriptions;
> $form->addElement('select',
> 'select_name', // name of select
> 'select_label', // label for select
> $select_data);
>
> I just can't see how to set the"<option value>" to values I can use - I
> don't want the default option values which are being created. (0,1,2...n)
>
> Is this possible to achieve?
Sure, you have to pass an associative array, where the keys are your
values for the options tag. For example following data array:
$arr = array ('Franz' => 'Option 1',
'Helmut' => 'Option 2'}
results in
<option value="Franz">Option 1</option>
<option value="Helmut">Option 2</option>
greetings,
Stefan