How to Subtract(-),Divide(/) Two text box values Running tim
Hi Developers,
My Query is working fine for sum of Two numbers Addition(+).
But I need Subtract and Divide Action of that text Box,
i cant able to Done it and also by Google it.
i am adding - instead of + but i didn't get exact output.
So help me to How am Perform Subtract and Divide Options on Running time.
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
//Iterate through each Textbox and add keyup event handler
$(".clsTxtToCalculate").each(function () {
$(this).keyup(function () {
//Initialize total to 0
var total = 0;
$(".clsTxtToCalculate").each(function () {
// Sum only if the text entered is number and greater than 0
if (!isNaN(this.value) && this.value.length != 0) {
total = total - parseFloat(this.value);
}
});
//Assign the total to label
//.toFixed() method will roundoff the final sum to 2 decimal places
$('#<%=lblTotalPrice.ClientID %>').html(total.toFixed(2));
});
});
});
</script>
<table border="1px" cellpadding="5" style="border-collapse: collapse;">
<tr style="text-align: left;">
<th>
No.</hd>
<th>
Item
</th>
<th>
Price
</th>
</tr>
<tr>
<td>
1
</td>
<td>
Milk:
</td>
<td>
<asp:TextBox ID="txtMilk" CssClass="clsTxtToCalculate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
2
</td>
<td>
Bread:
</td>
<td>
<asp:TextBox ID="txtBread" CssClass="clsTxtToCalculate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<b>Total Price</b>
</td>
<td>
<asp:Label ID="lblTotalPrice" runat="server"></asp:Label>
</td>
</tr>
</table>
Sorry For Repeated Posts Friends
Thanking You
Paul.S