<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Calculation additon and average for 4 number</title> | |
<p><u>This calculate total and average</u></p> | |
<script language="javascript"> | |
function calc() | |
{ | |
var bttntotal = document.getElementById("B1"); | |
var bttnaverage = document.getElementById("B2"); | |
var mark1 = parseFloat(document.Marks.mark1.value); | |
var mark2 = parseFloat(document.Marks.mark2.value); | |
var mark3 = parseFloat(document.Marks.mark3.value); | |
var mark4 = parseFloat(document.Marks.mark4.value); | |
if (bttntotal.checked){ | |
document.Marks.result.value = mark1+mark2+mark3+mark4; | |
}else if (bttnaverage.checked) { | |
document.Marks.result.value = ( mark1+mark2+mark3+mark4)/4; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<form name="Marks"> | |
<ul style type=none> | |
Marks: <input type="text" name="mark1" min="0" max="100"><br><br> | |
Marks: <input type="text" name="mark2" min="0" max="100"><br><br> | |
Marks: <input type="text" name="mark3" min="0" max="100"><br><br> | |
Marks: <input type="text" name="mark4" min="0" max="100"><br><br> | |
</ul> | |
<ul> | |
<input type="radio" name="calculate" value="bttntotal" id="B1">Find Total   | |
<input type="radio" name="calculate" value="bttnaverage" id="B2">Find Average<br></br> | |
<input type="button" value="Submit" onclick="calc()">         | |
<input type="reset" value="Clear"/> | |
<br></br>Result: <input type="text" name="result"><br> | |
</ul> | |
</form> | |
</body> | |
</html> |
Monday, 29 February 2016
Addition operation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment