xataku_nakusute
07-25-2003, 02:45 PM
im trying to make a calculator-like script just to test out....and i have it set so that it will calculate the value of inputs a and b......however, this produces odd(yet funny as heck) answers such as 1+1=11 and 0+1=01(that one works..)
so basically, my "calculator" is just concatenating the inputted data.......and becuz of this odd bug, ive named my code: "Baby's First Calculator" hehe
my code is included, pleaz help me to get it to actually add!!!
<html>
<body>
<script type="text/javascript">
function add(a1,a2)
{
a1 = document.calculator.add1.value
a2 = document.calculator.add2.value
equals = a1+a2
document.write(equals);
}
</script>
<center>
<h1>"Baby's First Calculator"</h1>
<p>
<form name="calculator">
<input name="add1" type="text" maxlength="10000000" size="1"> +
<input name="add2" type="text" maxlength="10000000" size="1">
<input value="Add" type="button" onclick="add()">
<input value="Reset" type="reset">
</form>
</center>
</body>
</html>
so basically, my "calculator" is just concatenating the inputted data.......and becuz of this odd bug, ive named my code: "Baby's First Calculator" hehe
my code is included, pleaz help me to get it to actually add!!!
<html>
<body>
<script type="text/javascript">
function add(a1,a2)
{
a1 = document.calculator.add1.value
a2 = document.calculator.add2.value
equals = a1+a2
document.write(equals);
}
</script>
<center>
<h1>"Baby's First Calculator"</h1>
<p>
<form name="calculator">
<input name="add1" type="text" maxlength="10000000" size="1"> +
<input name="add2" type="text" maxlength="10000000" size="1">
<input value="Add" type="button" onclick="add()">
<input value="Reset" type="reset">
</form>
</center>
</body>
</html>