Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to multiply two text box values Using the query the result to Display in one label Can u any one please tell me the Error following in my query


C#
$(function () {
            $("[id*=txtQuantity]").keyup(function () {
                debugger;
                var price = parseFloat($("[id*=txtPrice]").val());
                var Qnt = parseFloat($("[id*=txtQuantity]").val());
                var total = parseFloat(price * qnt);
                $("[id*=lblPrice]").val(total);
            });
        });



XML
<tr bgcolor="#ececec" style="width: 50%">
                                                <td class="style10" align="left">
                                                    &nbsp; <span style="font-family: 'Arial Narrow'; font-size: medium;" class="lblleabl">
                                                        &nbsp;Price</span>
                                                </td>
                                                <td class="style10" align="left">
                                                    <%-- <asp:TextBox ID="txtPrice" runat="server" class="Price"></asp:TextBox>--%>
                                                    <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr bgcolor="#ececec" style="width: 50%">
                                                <td class="style10" align="left">
                                                    &nbsp; <span style="font-family: 'Arial Narrow'; font-size: medium;" class="lblleabl">
                                                        &nbsp;Quantity</span>
                                                </td>
                                                <td class="style10" align="left">
                                                    <asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr bgcolor="#ececec" style="width: 50%">
                                                <td class="style10" align="left">
                                                    &nbsp; <span style="font-family: 'Arial Narrow'; font-size: medium;" class="lblleabl">
                                                        &nbsp;Total Price </span>
                                                </td>
                                                <td class="style10" align="left">
                                                    <%--<asp:Label ID="lblPrice" runat="server" Text=""></asp:Label>--%>
                                                    <asp:TextBox ID="lblPrice" runat="server"></asp:TextBox>
                                                </td>
                                            </tr>
Posted
Updated 12-Nov-20 19:20pm
v2
Comments
Jameel VM 4-Sep-13 8:06am    
check the error in console of chrome or mozilla
Thomas ktg 4-Sep-13 8:12am    
Qnt vs qnt there is difference between these two. Check this
Jameel VM 4-Sep-13 8:21am    
JavaScript variable names are case sensitive.so Qnt and qnt are different
Thomas ktg 4-Sep-13 8:26am    
that's fine

Yes,variable are case sensitive...

$(function () {
$("[id*=txtQuantity]").keyup(function () {
debugger;
var price = parseFloat($("[id*=txtPrice]").val());
var Qnt = parseFloat($("[id*=txtQuantity]").val());
var total = parseFloat(price * Qnt);
$("[id*=lblPrice]").val(total);
});
});
 
Share this answer
 
Comments
Member 14552976 3-Sep-19 4:29am    
i try this, works fine for the first row ,in second row it adds a same result,what should i do?
Check This.........

<pre>

$('input[name="txtQuantity"]').keyup(function() {
var a = $('input[name="txtPrice"]').val();
var b = $(this).val();
$('input[name="lblPrice"]').val(a * b);
});
 
Share this answer
 
$('[id^="qty_"]').change(function() {

var ID = $(this).attr("id");
var a=0;
var a1=0;

ID = ID.substring(4, 6);
ID = ID.replace("_","");

$('input[id^="qty_'+ID+'_"]').keyup(function() {
var a = $('input[id^="qty_'+ID+'_"]').val();

var b = $(this).val();
$('input[name="lblPrice"]').val(a * b);
var imp="tot_"+ID;


var c = a * b;

$('#'+imp).val(c);
});
 
Share this answer
 
Comments
Richard Deeming 13-Nov-20 4:41am    
An unformatted, unexplained code-dump is not a solution to this already-solved question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900