JavaScript IS case sensitive when you use "if" it has to be lower case.
Also, any document object has to be within a function, if it's outside it won't work. Here it is:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<script language = "javascript">
function calculate()
{
document.emarks.numofcoursestxt.value = "0"
document.emarks.totalcosttxt.value ="0"
var numofcourses = 0;
var totalcost, addmarks;
addmarks = parseInt(document.emarks.addmarkstxt.value);
if (addmarks<=4) {totalcost = addmarks*5};
if (addmarks>=5) {totalcost = addmarks*10}
if (addmarks>=10) {totalcost =addmarks*15};
totalcost+= totalcost;
numofcourses = numofcourses + 1;
document.emarks.numofcoursestxt.value = numofcourses;
document.emarks.totalcosttxt.value = totalcost;
}
</script>
</head>
<body>
<form name = "emarks">
<b>E-Marks:</b>
<p>
ID <input name = "idtxt" type = "text" size="5"><br>
Course Number <input name = "coursenumtxt" type = "text" size="5"><br>
Description <input name = "descriptiontxt" type = "text" size="10"><br>
Distance Education <input name = "dised" Checked type = "checkbox" value="off"><br>
Additional marks <input name = "addmarkstxt" type = "text" size="5"><br><br>
Number of courses <input name = "numofcoursestxt" type = "text" size="5">
Total Cost <input name = "totalcosttxt" type = "text" size="5"><br><br>
<input type = "button" value = "Go for it" onclick= "calculate()"> <input type = "button" value = "Clear and Reset">
</p>
</form>
</body>
</html>
Bookmarks