Calculator using html and javascript

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>CALCULATOR</title>
</head>
<script>
function myAdd()
{

var x = document.getElementById(“text1”).value;
var y = document.getElementById(“text2”).value;
var z=(x-0)+(y-0);
document.getElementById(“text”).value = z;
return true;
}
function mySub()
{

var x = document.getElementById(“text1”).value;
var y = document.getElementById(“text2”).value;
var z=(x)-(y);
document.getElementById(“text”).value = z;
return true;
}
function myMul()
{

var x = document.getElementById(“text1”).value;
var y = document.getElementById(“text2”).value;
var z=(x)*(y);
document.getElementById(“text”).value = z;
return true;
}
function myDiv()
{

var x = document.getElementById(“text1”).value;
var y = document.getElementById(“text2”).value;
var z=x/y;
document.getElementById(“text”).value = z;
return true;
}
function myRoot()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.sqrt(x);
document.getElementById(“text”).value = z;
return true;
}
function myAbs()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.abs(x);
document.getElementById(“text”).value = z;
return true;
}
function myCos()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.cos(x);
document.getElementById(“text”).value = z;
return true;
}
function mySin()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.sin(x);
document.getElementById(“text”).value = z;
return true;
}
function myTan()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.tan(x);
document.getElementById(“text”).value = z;
return true;
}
function myExp()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.exp(x);
document.getElementById(“text”).value = z;
return true;
}
function myLog()
{
var x = document.getElementById(“text1”).value;
//var y = document.getElementById(“text2”).value;
var z=Math.log(x);
document.getElementById(“text”).value = z;
return true;
}
function myPow()
{
var x = document.getElementById(“text1”).value;
var y = document.getElementById(“text2”).value;
var z=Math.pow(x,y);
document.getElementById(“text”).value = z;
return true;
}
function myReset()
{
document.getElementById(“MyCalculator”).reset();
}
</script>
<body bgcolor=”#3399FF”>
<form id=”MyCalculator”>
<div align=”center” style=”position:fixed; width:100%; bottom:0; margin-bottom:0; margin-right:20%; “><img src=”himanshu.jpg” height=”100″ width=”100″><br><font style=”bottom:0″ color=”#66FFFF” size=”+2″>Created by Himanshu Srivastava</font></div>
<p align=”center”><font size=”20″ color=”#3300CC”>CALCULATOR</font></p>
<table align=”center” border=”” cellspacing=”10″ cellpadding=”10″ bordercolor=”#00FFCC”>
<tr><td><font color=”#3300CC”>VALUE 1:</font><input type=”text” id=”text1″ value=”” size=”10″ /></td></tr>
<tr><td><font color=”#3300CC”>VALUE 2:</font><input type=”text” id=”text2″ value=”” size=”10″ /></td></tr>
<tr><td><font color=”#CC0000″>ANSWER:</font><input type=”text” id=”text” value=”” size=”10″ /></td></tr></table>
<table align=”center” border=”” cellspacing=”10″ cellpadding=”10″ bordercolor=”#00FFCC”>
<td><input type=”button” id=”button” value=”+” onclick=”myAdd()” size=”2″/></td>
<td ><input type=”button” id=”button” value=”-” onclick=”mySub()” size=”2″/></td>
<td ><input type=”button” id=”button” value=”*” onclick=”myMul()” size=”2″/></td>
<td ><input type=”button” id=”button” value=”/” onclick=”myDiv()” size=”2″/></td>
<td ><input type=”button” id=”button” value=”sqrt” onclick=”myRoot()” size=”2″/></td>
<td ><input type=”button” id=”button” value=”Abs” onclick=”myAbs()” size=”2″/></td>
<tr><td><input type=”button” id=”button” value=”Cos” onclick=”myCos()” size=”2″/></td>
<td><input type=”button” id=”button” value=”Sin” onclick=”mySin()” size=”2″/></td>
<td><input type=”button” id=”button” value=”Tan” onclick=”myTan()” size=”2″/></td>
<td><input type=”button” id=”button” value=”exp” onclick=”myExp()” size=”2″/></td>
<td><input type=”button” id=”button” value=”log” onclick=”myLog()” size=”2″/></td>
<td><input type=”button” id=”button” value=”pow” onclick=”myPow()” size=”2″/></td>
<td><input type=”reset” id=”reset” value=”reset” onclick=”myReset()” /></td></tr>
</table>
</form></body></html>

Image

Advertisements

About pinku12

HIMANSHU SRIVASTAVA VARANASI
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s