View Full Version : Interesting Checkbox problem


jamingben
04-07-2006, 03:55 PM
Well I think it's interesting anyway!

I am trying to make a color pallet on my site - like you have in a paint program, so users can submit a color choice through a form. Obviously this can be done simply with a drop down box or something but I want to try and make a color pallet.

I thought the best way to display this would be to use checkboxes, and have used <a href="http://www.brainerror.net/scripts_js_checkbox.php">this</a> script to change the checkbox images, so I am half way there, but I need every checkbox image to be different.

Is there a way of adjusting this script so that it can display different images on differet boxes?

Or could I just but some css on each box, so that the background color is different for every box (I have tried this but it didn't seem to work).

Thanks in advance for your help
Ben

G-commer
04-07-2006, 05:25 PM
Here is a script that might help:
<script language="JavaScript" type="text/javascript">
var colors=new Array(); //array of colors.
colors[0]="#0000FF"; //Blue
colors[1]="#00FF00"; //Green
colors[2]="#FF0000"; //Red
////////Don't edit past here/////////
var html="";
for(var i=0;i<colors.length;i++) html+="<input type='checkbox' style='background-color:"+colors[i]+";' />";
document.write(html);
</script>
Put that inside a <form>.