TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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;
<script src=
"scripts/jquery-3.3.1.js"
></script>
<script src=
"scripts/jquery-3.3.1.min.js"
></script>
<script type=
"text/javascript"
>
$(
function
() {
$(
".CssPrice"
).on(
'change keyup paste'
,
function
() {
var
textBox =
this
;
var
Price = $(textBox).val();
var
tableRows = $(textBox).parent().parent().parent().parent().children();
if
(Price !=
""
) {
var
quantity = tableRows[2].children[0].innerHTML;
var
itemTotal = price * quantity;
tableRows[4].children[0].innerHTML = itemTotal;
}
else
tableRows[4].children[0].innerHTML =
""
;
});
});
</script>
<asp:GridView ID=
"GridItems"
runat=
"server"
AutoGenerateColumns=
"false"
OnRowDataBound=
"GridItems_RowDataBound"
OnRowEditing=
"OnRowEditing"
OnRowCancelingEdit=
"OnRowCancelingEdit"
OnDataBound=
"GridItems_DataBound"
>
<Columns>
<asp:BoundField DataField=
"RowNumber"
HeaderText=
"Row Number"
/>
<asp:TemplateField HeaderText=
"ItemCode"
>
<ItemTemplate>
<asp:DropDownList ID=
"ddlItemCode"
runat=
"server"
Width=
"150px"
AutoPostBack=
"true"
>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Quantity"
>
<ItemTemplate>
<asp:TextBox ID=
"TxtQuantity"
runat=
"server"
Text=
'<%# Bind("Quantity") %>'
></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Price"
>
<ItemTemplate>
<asp:TextBox ID=
"TxtPrice"
runat=
"server"
Text=
'<%# Bind("Price") %>'
OnTextChanged=
"TxtPrice_TextChanged"
AutoPostBack=
"true"
CssClass=
"CssPrice"
></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Amount"
>
<ItemTemplate>
<asp:TextBox ID=
"TxtAmount"
runat=
"server"
Text=
'<%# Bind("Amount") %>'
>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Reply
Answers (
3
)
Rotate an image
how to empty a data grid view without hiding or rebinding?