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
Prakash
NA
258
77.8k
Get value from dynamic generated text box
Aug 10 2016 3:37 AM
Hello Experts,
I want to create invoice for product.Using MVC and jquery
I have dynamic generated text box by clicking on add product button
I generated dynamic id for textbox but i cant get value from newly created textbox.
Please help
below the whole code
$(document).ready(function () {
function addRow() {
var html = '<tr>' +
'<td><select id="txtName" class="form-control"><option> Select Product</option><option> VITA-H 100ml</option><option> CAL-CM GOLD</option></td>' +
'<td><input type="text" id:"txtAmount_' + i + '" class="form-control" placeholder="Amount" onkeyup="calculateSubtotal();"></td>' +
'<td><input type="text" id="txtQyantity_' + i + '" class="form-control" placeholder="Qyantity" onkeyup="calculateSubtotal();"></td>' +
'<td><input type="text" id="txtTotalAmount_'+ i +'" class="form-control" placeholder="Total Amount"></td>' +
'<td><input type="button" id="btnadd" class="form-control btn btn-success" value="+ Add Product" /></td>' +
'<td><input type="button" id="btnremove" class="form-control btn btn-danger" value="- Remove Product" /></td>' +
'</tr>';
$(html).appendTo($("#Table1"));
i++;
};
$("#Table1").on("click", "#btnadd", addRow);
function deleteRow() {
var par = $(this).parent().parent();
par.remove();
};
$("#Table1").on("click", "#btnremove", deleteRow);
if ($("#txtTotalAmount").val().length == 0) {
$("#txtTotalAmount").val("0.00");
};
if ($("#txtsubtotal").val().length == 0) {
$("#txtsubtotal").val("0.00");
};
if ($("#DiscountApplied").val().length == 0) {
$("#DiscountApplied").val("0.00");
};
if ($("#TotalAmount").val().length == 0) {
$("#TotalAmount").val("0.00");
};
});
function calculateSubtotal() {
var Amount = document.getElementById('txtAmount_').value;
var Quantity = document.getElementById('txtQyantity').value;
var TotalAmount = Amount * Quantity;
$('#txtsubtotal').val(TotalAmount);
$('#txtTotalAmount').val(TotalAmount)
}
function calculateTotal() {
var Discount = document.getElementById('DiscountApplied').value;
var Subtotal = document.getElementById('txtsubtotal').value;
if (Discount > 0 && Subtotal > 0) {
var DiscountCalculate = (Discount * Subtotal)/100;
var Result = Subtotal - DiscountCalculate;
}
else {
var Result = 0;
}
$('#TotalAmount').val(Result);
}
Thank You
Reply
Answers (
3
)
Change second select background color using Jquery
How to call C# function from JavaScript?