Friday, May 6, 2011

Custom dropdown box using javascript ?

Can we write custom dropdown box using javascript,html,css. and also placing backgroung-image for that.

any sample example

From stackoverflow
  • Yes we can!

    Yuval A : Edited the question :)
    AnthonyWJones : +1 Shouldn't up vote really but since I was about to answer the same I guess it would be hypocritical not to ;)
    Chad Grant : I can't :(
  • Yes. Yahoo! managed it, should you want evidence.

  • Yes, and we can too =)

  • Yes you can create a custom dropdown box like element.

    You can use a div for this purpose and set the background-image property for that div.

    You can add ul as menu items. Nut you have to write code for event like mouseclick, mouseover, mouseout, keydown etc

  • yes you can. with css it goes like this.

    add couple of class to your css page, like this:

    .cmdUnbelievable
    {
        width:200px;
        font-family:Trebuchet MS;
        background-color:#0b5925;
        color:#d4d5d4; 
        border:dashed 2px #f2f2f2;
    }
    .cmdUnbelievable option
    {
        color:#f2f2f2;
        border-bottom:solid 0px white;
        border:dashed 2px #f2f2f2;
        margin-left:15px;
    }
    

    then give a class to your select box :

        <select class="cmdUnbelievable">
            <option>We are</option>
            <option>the knights</option>
            <option>who say Ni.</option>
        </select>
    
    scunliffe : @kumar mentions setting a background image... FYI if you try to set one on the option elements it won't work in IE.

0 comments:

Post a Comment