Hi. I have a very simple adding calculator to do written in JS. Can anybody please help me fill in the blanks please?
The end result should look like the attached screenshot and on pressing "Calculate", I would like an alert box to appear showing the result.
The code must be the simplest possible and MUST include the parseInt() function.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Assignment 2 - Exercise 3</title>
</head>
<body>
<script language="JavaScript">
var greeting;
greeting = "Hello. Please enter the numbers you would like added together.";
window.alert(greeting);
var myInt;
var myFloat;
myInt = parseInt(number1);
document.write(" ????????? ");
myFloat = parseFloat(number2);
document.write(" ????????? ");
</script>
<table width="45%" align="left" border="2" cellpadding="8">
<tr>
<td>
<h1>The Adding Calculator! </h1>
<form name="form1">
Enter some numbers in these boxes:
<center>
<p>
<input type="text" size="20" maxlength="20" name="number1" value="0">
+
<input type="text" size="20" maxlength="20" name="number2" value="0">
=
<input type="button" name="calculate" value="CALCULATE" onClick=" ???????????? ">
</form>
</center>
</td></tr>
</table>
</body>
</html>
Thank you as always. s



Reply With Quote



Bookmarks