ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 277.7k

How to get quantity multiply price in amount textbox by jque

Sep 28 2018 10:13 AM
Problem
 
How to get quantity multiply price in amount textbox by jquery asp.net .
 
I work on web application web form asp.net .
 
AND I need to get qunatity * price and result display on Amount
 
when i try to do that i get error
 
JavaScript runtime error: Unable to get property 'children' of undefined or null
 
reference .
 
this error on line var quantity = tableRows[2].children[0].innerHTML;
  1. <script src="scripts/jquery-3.3.1.js"></script>  
  2. <script src="scripts/jquery-3.3.1.min.js"></script>  
  3. <script type="text/javascript">  
  4. $(function () {  
  5. $(".CssPrice").on('change keyup paste'function () {  
  6. var textBox = this;  
  7. var Price = $(textBox).val();  
  8. var tableRows = $(textBox).parent().parent().parent().parent().children();  
  9. if (Price != "") {  
  10. var quantity = tableRows[2].children[0].innerHTML;  
  11. var itemTotal = price * quantity;  
  12. tableRows[4].children[0].innerHTML = itemTotal;  
  13. }  
  14. else  
  15. tableRows[4].children[0].innerHTML = "";  
  16. });  
  17. });  
  18. </script>  
  19. <asp:GridView ID="GridItems" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridItems_RowDataBound" OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit" OnDataBound="GridItems_DataBound" >  
  20. <Columns>  
  21. <asp:BoundField DataField="RowNumber" HeaderText="Row Number" />  
  22. <asp:TemplateField HeaderText="ItemCode">  
  23. <ItemTemplate>  
  24. <asp:DropDownList ID="ddlItemCode" runat="server" Width="150px" AutoPostBack="true" >  
  25. </asp:DropDownList>  
  26. </ItemTemplate>  
  27. </asp:TemplateField>  
  28. <asp:TemplateField HeaderText="Quantity">  
  29. <ItemTemplate>  
  30. <asp:TextBox ID="TxtQuantity" runat="server" Text='<%# Bind("Quantity") %>' ></asp:TextBox>  
  31. </ItemTemplate>  
  32. </asp:TemplateField>  
  33. <asp:TemplateField HeaderText="Price">  
  34. <ItemTemplate>  
  35. <asp:TextBox ID="TxtPrice" runat="server" Text='<%# Bind("Price") %>' OnTextChanged="TxtPrice_TextChanged" AutoPostBack="true" CssClass="CssPrice" ></asp:TextBox>  
  36. </ItemTemplate>  
  37. </asp:TemplateField>  
  38. <asp:TemplateField HeaderText="Amount" >  
  39. <ItemTemplate>  
  40. <asp:TextBox ID="TxtAmount" runat="server" Text='<%# Bind("Amount") %>' >  
  41. </asp:TextBox>  
  42. </ItemTemplate>  
  43. </asp:TemplateField>  
  44. </Columns>  
  45. </asp:GridView>

Answers (3)