vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Color Drop Down v1

Color Drop Down v1 - Posted By Michael (wrighty) on 21st Mar 08 at 9:27pm
This will add a color drop down to the right of the UBBC buttons. Very handy thing to have! {Smile}

<script>
/*Color Drop Down v1
Created By Wrighty
No Rip, Repost or Claiming*/

var color = {

    list: [
        ["Red","FF0000"],
        ["Green","00FF00"]
    ],

    _s: document.createElement('select'),
    _d: document.createElement('span'),
    _p: get('ubbc_buttons','id'),
    add: {
        colors: function(){
            color._s.options[0] = new Option('Choose Color','');
            for(i=0;i<color.list.length;i++){
                color._s.options[i+1] = new Option(color.list[i][0],color.list[i][1]);
            }
        },
        extra_features: function(){
            color._d.style.paddingLeft = '20px';
            color._s.onchange = function(){
                if(color._s.value!=''){
                    add_ubbc('[color='+color._s.value+']','[/color]');
                }
            };
        },
        drop_down: function(){
            color._d.appendChild(color._s);
            color._p.firstChild.insertBefore(color._d, color._p.firstChild.getElementsByTagName('br')[0]);
        }
    },
    build: function(){
        if(color._p){
            this.add.colors();
            this.add.extra_features();
            this.add.drop_down();
        }
    }
};
color.build();
</script>


To add more colours simply alter the following:

        ["Red","FF0000"],
        ["Green","00FF00"]


To add 'Blue' you would use this:

        ["Red","FF0000"],
        ["Blue","0000FF"],
        ["Green","00FF00"]


Global Footer

Re: Color Drop Down v1 - Posted By Cryhavoc_ (virtuoso) on 22nd Mar 08 at 7:09pm
You got it done eh? {Tongue Out}

Re: Color Drop Down v1 - Posted By Michael (wrighty) on 22nd Mar 08 at 8:08pm
Yup. Was nice and easy! ^_^

All (MOSTLY!) DOM! {Smile}