I am trying to use the button to delete the newly-added row if it was added by mistake. The row with its checkboxes, label and button gets added to the table, but the onclick event doesn't fire. Here's the relevant code snippet:
Expand|Select|Wrap|Line Numbers
- var tbl = document.getElementById('tblSelectedServices');
- var tbody = tbl.tBodies[0];
- var newRowNum = tbl.rows.length;
- var svc = ddl[ddl.selectedIndex].value;
- var newRow = document.createElement('TR');
- var delcol = document.createElement('TD');
- var delbtn = document.createElement('INPUT');
- delbtn.setAttribute('type','button');
- delbtn.setAttribute('id','del' + newRowNum);
- delbtn.setAttribute('style','WIDTH: 17px; HEIGHT: 17px;');
- delbtn.setAttribute("onclick","removeRow(" + newRowNum + ");");
- delcol.appendChild(delbtn)
- newRow.appendChild(delcol);
- ..... add more stuff .....
- tbl.firstChild.appendChild(newRow);
What am I missing??