Apr 04

Javascript Dropdown

Back when i was working at UBC one site i had to develop wanted a dropdown box for selecting colour like that from another website. the method i did was to use a jquery addon which turned a select drop down into a div one just to add icons to the options, not to mention it required jQuery.

But more and more i am finding that jQuery isn’t as useful as it used to be now that Javascript has been catching up and loading up extra libraries so as i was waiting for some .wma files to covert to .mp3 (like 6,000 of them) i wrote up a javascript function which creates the HTML

now you can see from the example .html file how it works however you can also easily add icons to the menu items if you was creating a colour selector dropdwon, this can easily be done by generating the html for the icons and putting them in the text value of the object in the array that’s passed to the generator since the html in that will be outputted aswell

Also as this is broken up into separate elements each with their own classes it makes it esier to manipulate than your regular select dropdown thus avoiding a problem in Opera where you can’t change the background colour (that’s if it hasn’t been fixed in the past couple of months)

Leave a Reply

Your email address will not be published.