newhck / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

How would I add the "selected" marker to a dropdown selectbox #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, 
I have been trying to find out on my own but was Unlucky.

How can I add "selected" to a certain Element in my select-Box?

I am doing this:

$form->addSelect("$visible_name", $html_field_name, "", $all_row);

All Row contains Key -> Value pairs.
It works but I have got no clue how to make one of them slected?

Thanks for the help, the class is great.

Original issue reported on code.google.com by g1dan...@googlemail.com on 26 Jul 2010 at 5:59

GoogleCodeExporter commented 8 years ago
The third parameter of the addSelect() function controls the selected value.  
This needs to correspond with a key in your $all_row array.  You can also pass 
an array of keys for this parameter if you're using a select box with the 
multiple attribute.

Does this make sense?

- Andrew

Original comment by ajporterfield@gmail.com on 26 Jul 2010 at 6:07

GoogleCodeExporter commented 8 years ago
Hey Andrew, it works and thanks a lot for the quick response!!

Original comment by g1dan...@googlemail.com on 26 Jul 2010 at 6:14

GoogleCodeExporter commented 8 years ago

Original comment by moncojhr@gmail.com on 29 Jul 2010 at 5:25