I'd like to do some simple addition and multiplication with ASP .NET textboxes and jQuery, if possible.
Quantity One: <asp:Textbox ID="txtQuantity1" runat="server" />
Quantity Two: <asp:Textbox ID="txtQuantity2" runat="server" />
Total Quantity: <asp:Textbox ID="txtTotalQuantity" runat="server" ReadOnly="true" />
Price: <asp:Textbox ID="txtPrice" runat="server" ReadOnly="true" Text="5.00" />
Total Order: <asp:Textbox ID="txtTotalOrder" runat="server" ReadOnly="true" />
I'd like the user to enter quantity 1 and quantity 2 in the text boxes and the script to add those quantities then multiply by price for total order asynchronously.
Can anyone point me in the right direction? Thanks.
Edit - tried this, no luck:
<script type="text/javascript">
//<![CDATA[
var total = (parseInt($('#<%= txtQuantity1.ClientID %>').val()) + parseInt($('#<%= txtQuantity2.ClientID %>').val())) * parseInt($('#<%= txtPrice.ClientID %>').val()); ct100_BodyContent_txtTotalOrder.initialvalue = total;
//]]>
</script>
initialvaluein that code you posted, which doesn't exist. Usevalueinstead and you might have more success, or simplyalert(total)at that point to check you're getting the correct calculation.