javascript - After deletion changing id of textbox inside cell id not working -
i have table using javascript , deleting rows using delete function
after deletion trying reindex table cell ids
function updaterowcount(){ var table = document.getelementbyid("ordertable"); var rowcountafterdelete = document.getelementbyid("ordertable").rows.length; for(var i=1;i<rowcountafterdelete;i++){ table.rows[i].id="row_"+i; table.rows[i].cells[0].innerhtml=i+"<input type='checkbox' id='chk_" + + "'>"; table.rows[i].cells[1].id="notes_"+i; table.rows[i].cells[2].id="amount"+i; } }
but following lines not working:
table.rows[i].cells[1].id="notes_"+i; table.rows[i].cells[2].id="amount"+i;
<td>
's contains input boxes, this
<td><input type="text" title="notes"></td> <td><input type="text" title="amount"></td>
how can change id of text box inside <td>
or cell ?
i made jsfiddle here https://jsfiddle.net/an87ka5p/
i updated answer question in comments
function test() { var table = document.getelementbyid("ordertable"); var rowcountafterdelete = table.rows.length; (var = 0; < rowcountafterdelete; i++) { table.rows[i].id = "row_" + i; table.rows[i].cells[0].innerhtml = + "<input type='checkbox' id='chk_" + + "'>"; table.rows[i].cells[1].getelementsbytagname("input")[0].id = "notes_" + i; table.rows[i].cells[2].getelementsbytagname("input")[0].id = "amount_" + i; } }
Comments
Post a Comment