c# - Javascript Code wont run when changing TextBox Format -


hi using below java script code make calculation in asp grid-view

the code wont run if change textbox format in grid-view

for example

<itemtemplate> <asp:textbox id="txtcalccommision" textmode="number" placeholder="eenter commision" runat="server" cssclass="form-control"  ></asp:textbox> </itemtemplate> </asp:templatefield> 

other code runs perfectly

javascript code

<script type="text/javascript">      $(document).ready(function () {          $("[id*=gvproducts]input[type=text][id*=txtcalc]").on('keyup', (function (e) {              var costprice = $(this).closest('tr').find("input[type=text][id*=txtcalccostprice]").val();             var quantity = $(e.target).closest('tr').find("input[type=text][id*=txtcalcquantity]").val();             var commision = $(this).closest('tr').find("input[type=text][id*=txtcalccommision]").val();             var getunitprice = (parsefloat(commision / 100 * costprice)) + parsefloat(costprice);             var total = getunitprice * quantity;             $(e.target).closest('tr').find("[id*=lblunitprice]").text(getunitprice);             $(e.target).closest('tr').find("[id*=lbltotal]").text(total);             grosstotal();         }));      });      var gross;      function grosstotal() {          gross = 0;          $("[id*=gvproducts][id*=lbltotal]").each(function (index, item) {             gross = gross + parseint($(item).text());         });         $("[id*=lblgrandtotal]").text(gross);     } </script> 

add clientidmode="static" textbox. asp.net change id when page rendered, unless set clientidmode "static".

also have tried putting debugger; line inside keyup function? might hitting line, code in function isn't running properly.

[id*=gvproducts] isn't included in html provided. can't tell if that's affecting css selector finding textbox control.

<itemtemplate> assumes coming repeater... in case, you're better off using $("input.form-control") find control. asp.net whole bunch of things uniqueify id when it's inside repeater.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -