For More Help Ya guides Visit our Fb Page
https://www.facebook.com/vukhi01/
<html>
<head>
<title></title>
<script>
var firstvalue,secondvalue,operator,sum,total;
function FirstValue()
{
if(document.getElementById("inputbox").value=="")
{
window.alert("Enter A correct number!");
}
else
{
firstvalue=parseInt(document.getElementById("inputbox").value);
operator=document.getElementById("plus").value;
sum=firstvalue + operator;
document.getElementById("info").innerHTML=sum;
document.getElementById("inputbox").value="";
document.getElementById("plus").disabled = true;
document.getElementById("equal").disabled = false;
document.getElementById("inputbox").autofocus = true;
}
}
function SecondValue()
{
if(document.getElementById("inputbox").value=="")
{
window.alert("Enter A correct number!");
}
else
{
secondvalue=parseInt(document.getElementById("inputbox").value);
total=firstvalue + secondvalue;
total=total+"";
document.getElementById("info").innerHTML="";
document.getElementById("inputbox").value=total;
document.getElementById("plus").disabled = false;
document.getElementById("equal").disabled = true;
}
}
function clean()
{
if(document.getElementById("inputbox").value=!"")
{
document.getElementById("inputbox").value=0;
document.getElementById("info").innerHTML="";
document.getElementById("plus").disabled = false;
document.getElementById("equal").disabled = false;
firstvalue=0;
secondvalue=0;
total=0;
}
}
</script>
</head>
<body>
<h1>Addition Calculator</h1>
<div id="info">
</div>
<table name="mytable" border="2" width="20%" height="100">
<tr><td><input type="text" id="inputbox" name="calculationbar" value="0" size="30" autofocus></td></tr>
<tr>
<td><input type="submit" id="plus" name="plusbutton" value="+" onclick="FirstValue()">
<input type="submit" id="clear" name="clearbutton" value="C" onclick="clean()"></td>
</tr>
<tr>
<td><input type="submit" id="equal" name="equalbutton" value="=" onclick="SecondValue()"></td>
</tr>
</table>
</body>
</html>
Comments
Post a Comment