Monday, December 13, 2010

CALCULATOR

Hey guys another fine piece of javascripting for u all.U can now made a calculator of your own just like i have made.Mine is a simple one so u can enhance it.Coding given below.






<html>
<head><title>Calculator</title>
<script language="javascript">
var inputstring=""
function updatestring(value)
{inputstring+=value;
document.calculator.input.value=inputstring;
}
</script>
</head>
<body>
<form name="calculator">
<table border=5 bordercolor=red bgcolor="#ffffcc"><tr><td>
<input type="text" name="input" maxlength=15 size=27><br/>
<input type="button" value="  clear  " onclick="input.value=' ';inputstring=' ' ">
<input type="button" value="  mod    " onclick="updatestring('%')">
<input type="button" value="*" onclick="updatestring('*')"><br />
<input type="button" value="7" onclick="updatestring('7')">
<input type="button" value="8" onclick="updatestring('8')">
<input type="button" value="9" onclick="updatestring('9')">
<input type="button" value="/" onclick="updatestring('/')"><br/>
<input type="button" value="4" onclick="updatestring('4')">
<input type="button" value="5" onclick="updatestring('5')">
<input type="button" value="6" onclick="updatestring('6')">
<input type="button" value="+" onclick="updatestring('+')"><br/>
<input type="button" value="3" onclick="updatestring('3')">
<input type="button" value="2" onclick="updatestring('2')">
<input type="button" value="1" onclick="updatestring('1')">
<input type="button" value="-" onclick="updatestring('-')"><br/>
<input type="button" value="0" onclick="updatestring('0')">
<input type="button" value="00" onclick="updatestring('00')">
<input type="button" value="." onclick="updatestring('.')">
<input type="button" value="=" onclick="input.value=eval(inputstring);">
</td></tr>
</table>
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function confirmation()
{var answer=confirm("SATISFIED WITH THE CALCULATOR?")
if(answer)
{alert("THANKS FOR USING.HAVE A NICE DAY!!")
}
else
{alert("GIVE IT ANOTHER TRY")
}
}
</script>
</head>
<body>
<input type="button" value="click here" onclick="confirmation()">
</body>
</html>

  

js give it a try.Its not difficult to understand.Hope u all will enjoy it.