Forum Moderators: open
for event handling
HTML:
<input class="text" type="button" name="add" value="add more »" onclick="addRow(this.parentNode.parentNode)" />
I want to make some change with the function.
I want to add a function that deletes the row created by js
how to perform such?
Please help me. Any help and suggestions will be highly appreciated.
Thank you
A couple of pointers on your function though, you should use document.getElementsById for your table, it's more reliable. If the INPUT was suddenly nested in something else, say a DIV for some reason, it would break your code.
You could also use this method:
function addRow( evt) {
var e = evt ¦¦ event;
var obj = e.target ¦¦ e.srcElement;
and take this.parentNode.parentNode out of your onClick parameter on the INPUT tag. obj then becomes your INPUT box.
Then to find the table have
var table = obj.parentNode;
while( table.tagName!= "TABLE") table = table.parentNode;
Something like that.
Anyway, deleteRow is the function you were after.