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(form)
{
var colorArray = new Array(3);
var box1Index, box2Index, box3Index;
var myString='';
box1Index=document.form1.color1.selectedIndex;
box2Index=document.form1.color2.selectedIndex;
box3Index=document.form1.color3.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="second";
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 validateOnSubmit(form)
{
/*??????*/
}
</script>
</HEAD>
<BODY>
<form name=form1 onsubmit="validateOnSubmit(this.form)">
Pick color 1:
<SELECT id=color1 name=color1 style="WIDTH: 180px">
<OPTION value = "0">Select a color
<OPTION value = "1" name="blue">Blue
<option value = "2" name="red">Red
<option value = "3" name="black">Black
</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">Blue
<option value = "2" name="red">Red
<option value = "3" name="black">Black
</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">Blue
<option value = "2" name="red">Red
<option value = "3" name="black">Black
</OPTION></SELECT>
<br>
<input TYPE=BUTTON NAME="cmdCalc" VALUE="GO"
onClick=displayColors(this.form)>
</BODY>
</HTML>