:: Forum >>

how to implement a color picker combo?

i want see if i can use the combo control to implement a color picker. it would have a handful of the "standard" colors such as black, blue, red, gray, green, purple, with either the text in that color, or a color box next to the text.

since i have only a few colors i don't need those fancy palette or slider stuff.

i don't really want to create separate .gif or .jpg for each color. it will not be used inside the grid widget.

thanks for any help!
heidit
Wednesday, August 9, 2006
You can use css to make colored boxes (without .gif images) -

<style>

.aw-image-black {background-color: #000000;}
.aw-image-blue {background-color: #0000FF;}
.aw-image-green {background-color: #00FF00;}
.aw-image-red {background-color: #FF0000;}
.aw-image-yellow {background-color: #FFFF00;}
.aw-image-white {background-color: #FFFFFF;}

#myColors .aw-item-image, #myColors-popup .aw-item-image {
    border: 3px solid #fff;
}


</style>
<script>


    var colorsText = ["Black", "Blue", "Green", "Red", "Yellow", "White"];
    var colorsImage = ["black", "blue", "green", "red", "yellow", "white"];

    var obj = new AW.UI.Combo;
    obj.setId("myColors");
    obj.setItemText(colorsText);
    obj.setItemImage(colorsImage);
    obj.setItemCount(6);
    document.write(obj);

    // update textbox image
    obj.onSelectedItemsChanged = function(items){
        this.setTimeout(function(){
            this.setControlImage(this.getItemImage(items[0]));
        });
    }

</script>
Alex (ActiveWidgets)
Thursday, August 10, 2006
works perfectly! looks REALLY nice! thank you alex!
heidit
Thursday, August 10, 2006

This topic is archived.


Back to support forum

Forum search