Prakash

Prakash

  • NA
  • 258
  • 78.6k

Dynamic generate id

Jul 29 2016 2:47 AM
Hello Experts,
 
 
i want to generate dynamic id for textbox and button.
 
$(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" class="form-control" placeholder="Amount"></td>' +
'<td><input type="text" id="txtQyantity" class="form-control" placeholder="Qyantity" ></td>' +
'<td><input type="text" id="txtTotalAmount" 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"));
};
/
$("#Table1").on("click", "#btnadd", addRow);
function deleteRow() {
var par = $(this).parent().parent();
par.remove();
};
};
});
 
when i click on "add product" button its add new row for product.But not getting different id for Textbox of new row. 
 
Please help me. 
 
Thank You 

Answers (7)