I have read through lots of postings here and around the net, and I even have books covering this subjective, but I just can't get it to work. I just can't get the Function to pick up the value of the "RadioDrink" variable. I have tried all sorts of combinations Using DOM methods like below and here using a collection (this) and (form) with no luck. Any help would be appreciated.
function ValDrink(form){
if (form.RadioDrink.value == "soup")
{
alert("Its soup OK!");
return true; // OK
}
======================here is my code.======================
<html>
<head>
<title>Test</title>
<script type="text/JavaScript">
<!--
function ValDrink()
{
if (document.forms.Drinks.RadioDrink.value == "soup")
{
alert("Its soup OK!");
return true; // soup
}
else
{
alert("OK");
return false; // not soup
}
}
//-->
</script>
</head>
<body>
<form method="post" id="Drinks" name="Drinks" onsubmit="return ValDrink()">
<input type="radio" checked name="RadioDrink" value="Tea">Tea<br>
<input type="radio" name="RadioDrink" value="Coffee">Coffee<br>
<input type="radio" name="RadioDrink" value="Soup">Soup<br>
<input type="checkbox" name="CheckMilk" value="Yes">Milk
<input type="checkbox" name="CheckSugar" value="Yes">Sugar
<br>
<input type="submit" name="OKButton" value="Vend">
</form>
</body>
</html>