Hi there!
Newbie here... :-)
I'm trying to validate a form but can't seem to get it to work... Here's a
copy of the code:
The user has to select a color for every select box. How is this done???
Many thanks
Ann
Ottawa Canada
*************** *
<HTML>
<HEAD>
<Title>My color test</Title>
<script>
function displayColors(f orm)
{
var colorArray = new Array(3);
var box1Index, box2Index, box3Index;
var myString='';
box1Index=docum ent.form1.color 1.selectedIndex ;
box2Index=docum ent.form1.color 2.selectedIndex ;
box3Index=docum ent.form1.color 3.selectedIndex ;
colorArray[0]=document.form1 .color1[box1Index].value;
colorArray[1]=document.form1 .color2[box2Index].value;
colorArray[2]=document.form1 .color3[box3Index].value
for (i=0; i<3; i++)
{
switch(i)
{
case 0:
myString="first ";
break;
case 1:
myString="secon d";
break;
case 2:
myString="third ";
break;
default:
myString=""
}
switch (colorArray[i])
{
case "1":
document.write( '<FONT COLOR="blue">') ;
document.write( "you selected blue as your " + myString +" color<br>")
document.write( '</FONT>')
break;
case "2":
document.write( '<FONT COLOR="red">');
document.write( "you selected red as your " + myString +" color<br>")
document.write( '</FONT>')
break;
case "3":
document.write( '<FONT COLOR="black">' );
document.write( "you selected black as your " + myString +" first
color<br>")
document.write( '</FONT>')
break;
default:
document.write( "no color<BR>");
}//end switch
}//end for
}//end function
function validateOnSubmi t(form)
{
/*??????*/
}
</script>
</HEAD>
<BODY>
<form name=form1 onsubmit="valid ateOnSubmit(thi s.form)">
Pick color 1:
<SELECT id=color1 name=color1 style="WIDTH: 180px">
<OPTION value = "0">Select a color
<OPTION value = "1" name="blue">Blu e
<option value = "2" name="red">Red
<option value = "3" name="black">Bl ack
</OPTION></SELECT>
<br><br>
Pick color 2:
<SELECT id=color2 style="WIDTH: 180px" name=color2>
<OPTION value = "0"> Select a color
<OPTION value = "1" name="blue">Blu e
<option value = "2" name="red">Red
<option value = "3" name="black">Bl ack
</OPTION></SELECT>
<br><br>
Pick color 3:
<SELECT id=color3 style="width: 180px" name=color3>
<OPTION value = "0"> Select a color
<OPTION value = "1" name="blue">Blu e
<option value = "2" name="red">Red
<option value = "3" name="black">Bl ack
</OPTION></SELECT>
<br>
<input TYPE=BUTTON NAME="cmdCalc" VALUE="GO"
onClick=display Colors(this.for m)>
</BODY>
</HTML>