|
|
Home Developer Manual 11. API Reference mosHTML::makeOption |
| mosHTML::makeOption |
|
|
|
|
Last reviewed: Not reviewed mosHTML::makeOption
This method returns an object that can be passed in an array to another list handling method such as mosHTML::selectList. The method takes two arguments, one for the value of the option tag and optionally one for the text to display. If the text is omitted the single string is used for both the option value and the text. Syntaxobject makeOption ( string $value [, string $text [, string $value_name [, string $text_name ] ] ] )
The mosHTML::makeOption method returns a stdClass object with class variables 'value' and 'text'. From Joomla 1.0 onwards the class variable names actually used can be overridden as described above. ExamplesExample 1: creating a list with hard coded values: // Option value and text will be the same. $mylist1 = array(); $mylist1[] = mosHTML::makeOption( 'Good' ); $mylist1[] = mosHTML::makeOption( 'Bad' ); $mylist1[] = mosHTML::makeOption( 'Ugly' ); // Option value and text will be different. $mylist2 = array(); $mylist2[] = mosHTML::makeOption( '0', 'Select priority' ); $mylist2[] = mosHTML::makeOption( '1', 'Low' ); $mylist2[] = mosHTML::makeOption( '2', 'High' ); Example 2: creating a list from a database query: // alias the 'value' and 'text' fields and the array will // be in the correct format. $users = array(); $users[] = mosHTML::makeOption( '0', 'Select user' ); $database->setQuery( "SELECT id AS value, username AS text FROM #__users" ); $users = array_merge( $users, $database->loadObjectList() ); Please report any errors on this page to the Developer Documentation Forum. |
|
| Last Updated ( Saturday, 31 May 2008 ) |
| < Prev | Next > |
|---|





