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
Praveen Kumar
NA
235
22.5k
Cannot read property 'replace' of undefined
Jul 8 2020 5:13 AM
function
Addcategory() {
// Get the index number
var
indexNo = $(
"#category-table > tr"
).length;
// Get the template row
var
newRow = $(
"#category-table > tr:eq(0)"
).clone().prop(
'outerHTML'
);
// Reset the indexes on the template
newRow = newRow.replace(/_0_/g,
"_"
+ indexNo +
"_"
);
newRow = newRow.replace(/\[0\]/g,
"["
+ indexNo +
"]"
);
// reset devextreme datepicker ids
newRow = newRow.replace(/devextreme0/g,
"devextreme"
+ parseInt(2 * indexNo));
newRow = newRow.replace(/devextreme1/g,
"devextreme"
+ parseInt(1 + 2 * indexNo));
// Append the row to the child table
$(
"#category-table"
).append(newRow);
// Make it visible
$(
"#category-table > tr:eq("
+ indexNo +
")"
).removeClass(
"hidden"
);
$(
"#category-table > tr:eq("
+ indexNo +
") > td:eq(8) > input"
).val(
"ADD"
);
$(
"#category-table > tr:eq("
+ indexNo +
") > td:eq(0) > input"
).val(
""
);
$(
"#category-table > tr:eq("
+ indexNo +
") > td:eq(4) > select"
).next().remove();
}
<div
class
=
"card"
>
<div
class
=
"card-header"
>
<div
class
=
"row"
>
<div
class
=
"col"
>
<h3
class
=
"card-title"
>Categories</h3>
</div>
<div
class
=
"col text-right"
>
<button title=
"Add tax category"
id=
"add-category"
class
=
"btn btn-default btn-sm"
type=
"button"
onclick=
"Addcategory()"
><i
class
=
"fa fa-plus"
></i></button>
</div>
</div>
</div>
<div
class
=
"card-body"
>
<div id=
"categorieErrorMsg"
>
@Html.ValidationMessageFor(model => model.Categories,
""
,
new
{ @
class
=
"text-danger"
})
</div>
<div id=
"category-values"
>
<table
class
=
"table table-condensed"
id=
"category-table"
>
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.Categories.First().Name)</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().InvoiceLabel)</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().TaxRate)</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().TaxCode)</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().Attribute)</th>
<th>Valid value</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().StartDate)</th>
<th>@Html.DisplayNameFor(model => model.Categories.First().EndDate)</th>
<th></th>
</tr>
</thead>
<tbody id=
"category-table"
>
@Html.EditorFor(model => model.Categories,
new
{ htmlAttributes =
new
{ @
class
=
"form-control"
} })
</tbody>
</table>
</div>
</div>
</div>
Reply
Answers (
6
)
Document conversion(xlsx,doc,ppt) to PDF from amazon s3 bicket
RegEx No more than 2 identical consecutive characters and a-Z and 0-9