searchsanjaysharma
asked on
How to subtract to two asp:textboxes in jquery
I have 2 text boxes in asp.net
<asp:Textbox id="t1" Text="" runat="server"/>
<asp:Textbox id="t2" Text="" runat="server"/>
<asp:Textbox id="t3" Text="" runat="server"/>
t3 is t1-t2
How to do this on value change in t1 and t2 both without postback and with jquery
<asp:Textbox id="t1" Text="" runat="server"/>
<asp:Textbox id="t2" Text="" runat="server"/>
<asp:Textbox id="t3" Text="" runat="server"/>
t3 is t1-t2
How to do this on value change in t1 and t2 both without postback and with jquery
t3= parseFloat($("#t1")) -parseFloat($("#t2"))
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this jsfiddle.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo by Proculopsis</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
</style>
<script type='text/javascript'>//<![CDATA[
$(function(){
$(".numeric").keyup(function() {
var t1 = $("#t1").val();
var t2 = $("#t2").val();
t1 = parseFloat(t1);
t2 = parseFloat(t2);
t1 = isNaN(t1) ? 0 : t1;
t2 = isNaN(t2) ? 0 : t2;
$("#t3").val(t1 - t2);
});
});//]]>
</script>
</head>
<body>
<input id="t1" class="numeric" />
<input id="t2" class="numeric" />
<input id="t3" />
</body>
</html>
ASKER
ok