0% found this document useful (0 votes)
19 views

Javascript

The document contains JavaScript functions to perform basic arithmetic operations of addition, subtraction, multiplication and division by getting numeric values from text boxes and displaying the result.

Uploaded by

Prashanth Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Javascript

The document contains JavaScript functions to perform basic arithmetic operations of addition, subtraction, multiplication and division by getting numeric values from text boxes and displaying the result.

Uploaded by

Prashanth Shetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<html>

<head>
<script>
function sum()
{
var a,b,c;
a=Number(document.getElementById("txt1").value);
b=Number(document.getElementById("txt2").value);
c=a+b
document.getElementById("answer").value=c;
}
function sub()
{
var a,b,c;
a=Number(document.getElementById("txt1").value);
b=Number(document.getElementById("txt2").value);
c=a-b
document.getElementById("answer").value=c;
}
function multi()
{
var a,b,c
a=Number(document.getElementById("txt1").value);
b=Number(document.getElementById("txt2").value);
c=a*b
document.getElementById("answer").value=c;
}
function div()
{
var a,b,c;
a=Number(document.getElementById("txt1").value);
b=Number(document.getElementById("txt2").value);
c=a/b
document.getElementById("answer").value=c;
}
</script>
</head>
<body bgcolor="turquoise">
<form>
<h1 align="center" style="color:purple">Arithmetic Operations</h1>
<center>Enter first Number
<input type="text" id="txt1" name="text1"><br><br>
Enter second Number
<input type="text" id="txt2" name="text2"><br><br>
<input type="button" value="Add" onclick="sum()"><br><br>
<input type="button" value="Subtract" onclick="sub()"><br><br>
<input type="button" value="Multiply" onclick="multi()"><br><br>
<input type="button" value="Division" onclick="div()"><br><br>
<input type="text" id="answer" name="text3">
</form>
</body>
</html>

You might also like