shady
12-19-2002, 03:22 PM
Whilst I have experience of VB6 and HTML, I'm only just learning JavaScript, I've read various tutorials, but still am at a loss as to what I have done wrong here. I have declared a function in the head of my HTML doc as follows.
<html>
<head>
<script language="JavaScript">
function calculation()
{
var mySupplier = document.supplier.value
switch (mySupplier)
{
case "Amerada" :
alert ("Amerada");
break;
case "Crown" :
alert ("Crown");
break;
default :
alert ("Other");
break;
}
}
</script>
</head>
and I am attempting to call this function from a button which is defined in the body of the HTML doc thus:-
<input type="button" value="Calculate" onClick="calculation" >
but when i click the button, nothing at all happens. I have a drop down box called supplier, and I am simply trying to get the page to recognise which option has been selected, eventually I am going to place calculations in the SWITCH - CASE statements. I.E. depending on the option selected a specific calculation will be executed and the result will be displayed in another text box. As this is my first stab at JavaScript, I require as much help as anyone can give.
Regards
Shady
<html>
<head>
<script language="JavaScript">
function calculation()
{
var mySupplier = document.supplier.value
switch (mySupplier)
{
case "Amerada" :
alert ("Amerada");
break;
case "Crown" :
alert ("Crown");
break;
default :
alert ("Other");
break;
}
}
</script>
</head>
and I am attempting to call this function from a button which is defined in the body of the HTML doc thus:-
<input type="button" value="Calculate" onClick="calculation" >
but when i click the button, nothing at all happens. I have a drop down box called supplier, and I am simply trying to get the page to recognise which option has been selected, eventually I am going to place calculations in the SWITCH - CASE statements. I.E. depending on the option selected a specific calculation will be executed and the result will be displayed in another text box. As this is my first stab at JavaScript, I require as much help as anyone can give.
Regards
Shady