Well I was writing a small jScript programs for fun. I wanted to have addition subtraction multipclication etc.
When I added the functions to be called by an html buton it did nothing.
Heres the code I used:
Code:
<html>
<head>
<title>Math calculator</title>
</head>
<body>
<script type="text/javascript">
//Math Calculator
//Code by Eddie Jones
function add(a,b,c)
{
var a = prompt("Enter first number", "Type number here");
var b = prompt("Enter second number", "Type number here");
var c = a+b;
document.write("Answer to addition problem is:"); document.write("<br>");
document.write("<br>");
document.write(c);
}
function multiply(d,e,f)
{
//getting variables to be used
var d = prompt("Enter first number", "Type number here");
var e = prompt("Enter second number, "Type number here");
//Answering the problem
var f = d*e;
//Multiplication answer
document.write("Answer to the mulplication problem is:"); document.write("<br>");
document.write("<br>")
document.write(f);
}
</script>
<input type="button" value="Addition" onclick="add()" > <br>
<br>
<input type="button" value="Multiplication" onclick="multiply()" >
</body>
</html>
I named it math and saved it. (I used the // tags to remember what that part of the code did, I wrote the multiplication w/o functions and had the tags there, I just didnt bother to get rid of them)
|