Gary Dickinson wrote:[color=blue]
> Hello Everybody,
>
> I have a table that has a delete button at the end of each row. I want
> the row to disappear/delete when the user clicks on the delete button
> for the corresponding row. I tried using the command
> mytable.deleteRow() for the button but no luck. Here is the url for the
> page.
http://24.84.131.118/modelviewer/index.html and the javascript
> is in
http://24.84.131.118/loader.js . This is my first attempt at[/color]
It's actually at:
<URL:http://24.84.131.118/modelviewer/loader.js>
[color=blue]
> javascript so all help will be greatly appreciated
>[/color]
Your onclick is;
<td><input type='button' value='X' onclick='
mytable.deleteRow()
'>
</td>
To delete a row, the syntax is table.deleteRow( index ) where 'table'
is a reference to a table and 'index' is the index of one of the rows.
You don't define 'mytable' or provide an index for which row to delete.
Try something like:
<td><input type='button' value='X' onclick='
delRow(this);
'>
</td>
And define delRow in your loader.js as:
function delRow(x) {
while ('TR' != x.nodeName.toUpperCase() ) {
x = x.parentNode;
}
var i = x.rowIndex;
while ('TABLE' != x.nodeName.toUpperCase() ) {
x = x.parentNode;
}
x.deleteRow(i);
}
--
RobG