Making custom drop down list using JHTML in Joomla

You can use the JHTML helper library to draw a custom drop down lists.


JHTML::_('select.genericlist', $dataArray, $name, $attributes, 
$valueField, $textField, $selectedValue);

The $dataArray must be an associative array like this


$arr[] = Array('val'=>1,'text'=>'Jan');
$arr[] = Array('val'=>2,'text'=>'Feb');

The $name is the name you want to give the drop down list.

The $attributes are the list properties you want to add.

The $valueField is name of the array field used for the actual value of list item.

The $textField is name of the array field used for the list item text to display.

This will display the dropdown named lstMonths with two months from $arr:


echo JHTML::_('select.genericlist', $arr, 'lstMonths', 'onChange=\"changeFunc()\"', 'val', 'text', $_POST['lstMonths']);

The actual select helper file is located in /libraries/joomla/html/html/select.php

Leave a comment

5 Comments.

  1. Can you post more about this JHTML select?
    I need to display a data from the database in a dropdownlist using JHTML select.

    • Where are the correct rom files for HTC EVO 4G Shift and unoort instructions?Do the HTC EVO 4G roms and unoort work on the HTC EVO 4G Shift?Would be nice if this site could have a top page link that will clairfy that works on what until I won’t take the risk of re roming my sprint phone. This seems to be the best site to watch so hopefully webmaster you will do this or send out a mass email news letter on roming a HTC EVO 4G Shift.Thanks

    • Revised fast typing while wkroing is a bad thing Well it’s been less than a year so not sure what this new EVO has to offer compare to the first version. My vote is wait it out until the original EVO is a year old.. and man i’m sure it comes with the same tag along fees as well.

    • So are my wife and I the only ones who are glad to see the end of the “pretty boy” Bonds Dalton and Brosnan? I still remember Brosnan’s stated wish that Bond be killed off in the last film, so he could be the last Bond.Bring on Craig, we’ll be comparing him to Connery and Moore, for us the ony real Bonds (Lazenby was fine, but his film wasn’t that great for other reasons).

    • I’ve found it a little difficult to find computer parts without having to buy whole computers and tearing them apart myself. . I want to start my own business using the computer parts, but where can I get the computer parts (the small parts)? I have tried my local recycle center and no success.. I’m on the verge of contacting an established computer craftsperson and cosigning to their business. . . Anyone with ideas or advice?.