Click here to Skip to main content
15,884,032 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello friends i am trying to do some basic calculations using jquery such rate into quantity minus discount percentage and add tax percentage like as follows i write the following code for that but i not working properly i want a suggestion from you please suggest me to do calculations
and Thanks in advance for always helping me..!

Here Is My jquery code
XML
<script type="text/javascript">
$(function () {
$("[id*=txt_part_quantity]").keypress(function () {

var price = parseFloat($("[id*=txt_part_rate]").val());
var Qnt = parseFloat($("[id*=txt_part_quantity]").val());
var total = parseFloat(price * Qnt);
$("[id*=txt_net_taxable_amt]").val(total);

/* When I entered a quantity then I get NaN in a TextBox Net Taxable Amount and in Discount Amount */

var dis = parseFloat($("[id*=txt_discount_percentage]").val());
var dis_amt = parseFloat(total * dis) / 100;
$("[id*=txt_discount_amount]").val(dis_amt);
var net_amt = amt - dis_amt;
$("[id*=txt_net_taxable_amt]").val(net_amt);
});
});
</script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#ddl_vat").change(function () {
            getVal();
        });
        getVal();
    });
    function getVal() {
        var a = $('#ddl_vat:selected').text();

    };
    </script>


and here is my C# ASP.NET Web Form

XML
<div class="form-group col-md-5">
    <label>
        Part Rate :
    </label>
    <asp:TextBox ID="txt_part_rate" runat="server" CssClass='form-control' placeholder="Part Rate" ClientIDMode="Static"></asp:TextBox>
</div>
<div class="form-group col-md-5">
    <label for="exampleInputPassword1">
        Part Quantity :
    </label>
    <asp:TextBox ID="txt_part_quantity" runat="server" CssClass='form-control' ClientIDMode="Static"
        placeholder="Part Quantity"></asp:TextBox>
</div>
<div class="form-group col-md-5">
    <label>
        Discount Percentage :
    </label>
    <asp:TextBox ID="txt_discount_percentage" runat="server" CssClass='form-control' placeholder="Discount Percentage" ClientIDMode="Static"></asp:TextBox>
</div>
<div class="form-group col-md-5">
    <label>
        Discount Amount :
    </label>
    <asp:TextBox ID="txt_discount_amount" runat="server" CssClass='form-control' placeholder="Discount Amount" ClientIDMode="Static"></asp:TextBox>
</div>
<div class="form-group col-md-5">
    <label>
        Net Taxable Amount :
    </label>
    <asp:TextBox ID="txt_net_taxable_amt" runat="server" CssClass='form-control' placeholder="Net Taxable Amount" ClientIDMode="Static"></asp:TextBox>
</div>
<div class="form-group col-md-5">
<label>
    TAX :
</label>
<asp:DropDownList ID="ddl_vat" runat="server" CssClass='form-control' ClientIDMode="Static">
</asp:DropDownList>
</div>
<div class="form-group col-md-5">
    <label for="exampleInputPassword1">
        TAX Amount :
    </label>
    <asp:TextBox ID="txt_vat_amount" runat="server" CssClass='form-control' placeholder="VAT Amount" ClientIDMode="Static"></asp:TextBox>
</div>
<div class="form-group col-md-5">
    <label>
        Total Amount :
    </label>
    <asp:TextBox ID="txt_total_amt" runat="server" CssClass='form-control' placeholder="Total Amount" ClientIDMode="Static"></asp:TextBox>
</div>



Please help me to do this
Thanks a lot for your time and your support
Posted
Updated 6-Dec-14 3:53am
v2
Comments
What is the issue here?
ZurdoDev 6-Dec-14 15:35pm    
Why doesn't it work? Where are you stuck?
Omkar Hendre 8-Dec-14 5:45am    
I am not getting Qty * Rate value in Net Taxable Amount and i am getting NaN in Discount Amount as well as in Net Taxable Amount
BacchusBeale 15-Dec-14 22:15pm    
to select element id you need $( "#myId" ); as on jQuery website.

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