Taipan
05-04-2007, 04:11 AM
Hi,
I want to stop my form from submitting if a select box value has not been chosen. When I use this code it works fine <script language="JavaScript" type="text/JavaScript">
function checkForm( form1 ) {
if( !document.form1.select.options[document.form1.select1.selectedIndex].value ) {
var answer = window.alert( "You did not select an option." );
if( answer ) {
return true;
} else {
return false;
}
}
return true;
}
</script>
but my select boxes are an array and instead of being called "select1" it is called "option[1]". If I subbstitute "option[1]" for "select1" in the javascript it no longer works. Can anyone help me with this?
I want to stop my form from submitting if a select box value has not been chosen. When I use this code it works fine <script language="JavaScript" type="text/JavaScript">
function checkForm( form1 ) {
if( !document.form1.select.options[document.form1.select1.selectedIndex].value ) {
var answer = window.alert( "You did not select an option." );
if( answer ) {
return true;
} else {
return false;
}
}
return true;
}
</script>
but my select boxes are an array and instead of being called "select1" it is called "option[1]". If I subbstitute "option[1]" for "select1" in the javascript it no longer works. Can anyone help me with this?