Hey folks,

I'm trying to create a color bar using Javascript so that users can click on a color, and add it to a div. So far I'm having trouble just creating the bar. Can someone help me by peeking at my code and seeing if they see any obvious mistakes?

When I debugged it in Firefox it was telling me that the value of webSafeColor was undefined, so I'm doing something incorrect, either in the creation of the array in the function colorDraw, or in the creation of the array in convertColor.

Code:
function colorDraw() {
   var num = 0;
	 var color = "";
	 var colorLoc = 0;
	 var hexcolor = "";
	 var divName = "";
	 var webSafeColor = new Array(convertColor());
   for (y=1;y<=216;y++){
	   colorLoc = num + y;
		 color = webSafeColor[y];
		 webColor = "#"+ String(color);
		 var newDiv = document.createElement('div');
		 divName = "div" + String(colorLoc);
		 newDiv.id = divName;
		 newDiv.style.backgroundColor = webColor;
		 newDiv.style.height = "2px";
		 newDiv.style.width = "50px";
		 document.getElementById('colordiv').appendChild(newDiv);
	 }
}
function convertColor() {
   var l=0;
   var webSafeColor = new Array(216);
   for (i=1;i<=6;i++) {
	     for (j=1;j<=6;j++) {
			     for (k=1;k<=6;k++) {
					 		 l = l + 1;
							 webSafeColor[l] = convertHex(i) + convertHex(j) + convertHex(k);
					 }
			 }
	 }
	 return webSafeColor;
}
function convertHex(input){
   var output = null;
   switch(input){
	     case 1:
		       output = "00";
				   break;
		   case 2:
		       output = "33";
					 break;
			 case 3:
			     output = "66";
					 break;
			 case 4:
			     output = "99";
					 break;
			 case 5:
			     output = "cc";
					 break;
			 case 6:
			     output = "ff";
					 break;
			 default:
           ;
	 }
	 return output;
}
window.onload = colorDraw;
Thanks for your help.

Dave