latest Post

Simple Calculator Program in JQuery

<html>
<head>
<script src="jquery.js"></script>
<script src="jquery-ui-1.10.3.custom.js">
</script>
<script>
$(document).ready(function(){
$("input[type=button]").click(function(){
v=$(this).val();
//alert(v);
num1=$("#tf1").val();
n1=parseFloat(num1);
num2=$("#tf2").val();
n2=parseFloat(num2);
if(v=="ADD")
r=n1+n2;
if(v=="SUB")
r=n1-n2;
if(v=="MUL")
r=n1*n2;
if(v=="DIV")
r=n1/n2;
if(v=="MOD")
r=n1%n2;
$("#res").val(r);
});
});
</script>
</head>
<body>
<form>
Enter First Number:
<input type="text" id="tf1"/><br>
Enter Second Number:
<input type="text" id="tf2"/><br>
Result:
<input type="text" id="res"/><br>
<input type="button" value="ADD"/>
<input type="button" value="SUB"/>
<input type="button" value="MUL"/>
<input type="button" value="DIV"/>
<input type="button" value="MOD"/>
</form>
</body>
</html>

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment