DHTML tables generate R6025 pure virtual function call error in IE6 any ideas??

S

Steve

hi all,
i'm using DHTML to generate a dynamic table with adding removing and
sorting rows
the thing is after a row has been added at a position that i specify,
if i try to delete it i get this error !
here's a chunk of code

<script language='javascript' type='text/css' >
function removeElement(divNum,arrayCode,elementId)
{

var dynamic_content_table=document.getElementById("dynamiccontent")
var row_to_delete=document.getElementById("tr"+elementId)
for(var
i=row_to_delete.rowIndex+1;i<dynamic_content_table.rows.length;i++)
{
var row=dynamic_content_table.rows
var the_span=row.cells[0].getElementsByTagName("span")
the_span[0].innerText=i-2
}
alert(row_to_delete.rowIndex)
dynamic_content_table.deleteRow(row_to_delete.rowIndex) // row
generating error
deleteId(divNum)
count--
updatecount()
elementId--
}

it happens if i try to add an element at a specific position using
function addElement(elementId,at_pos)
{
dynamic_content_table.insertRow(at_pos)
}
by the way the code works great in FF
appreciate the help
thanks
 
R

RobG

Steve said:
hi all,
i'm using DHTML to generate a dynamic table with adding removing and
sorting rows
the thing is after a row has been added at a position that i specify,
if i try to delete it i get this error !
here's a chunk of code

<script language='javascript' type='text/css' >
function removeElement(divNum,arrayCode,elementId)
{

var dynamic_content_table=document.getElementById("dynamiccontent")
var row_to_delete=document.getElementById("tr"+elementId)
for(var
i=row_to_delete.rowIndex+1;i<dynamic_content_table.rows.length;i++)
{
var row=dynamic_content_table.rows
var the_span=row.cells[0].getElementsByTagName("span")
the_span[0].innerText=i-2
}
alert(row_to_delete.rowIndex)
dynamic_content_table.deleteRow(row_to_delete.rowIndex) // row
generating error


Try adding/deleting rows using the tbody, not the table. I think the
simplest way to do that (given that you already have a reference to the
row you want to delete) is:

row_to_delete.parentNode.removeChild(row_to_delete);


Note that the tbody element exists whether its tags are in the source
HTML or not, it will be added by the browser.
 
R

RobG

Jim said:
This happens in IE - it's a known bug. You can't manipulate IE tables at
the DOM levelin this way (adding and removing elements).

Do you mean that you can't use delete row if you added a row using
insert row? The following test case below works fine in IE.

Generally you'll end up having to repaint the entire table.

I've never resorted to that except when sorting an entire table, and
then it is a matter of doing a shallow clone of the tbody, appending
the rows from the old table in order, then replacing the (now empty)
old tbody with the new one.

This strategy works nicely with tables that have one or more sections.
Anyhow, the demo below is just for insert/deleteRow.


<script type="text/javascript">

function addRows(tableID, num){
var t = document.getElementById(tableID);
var r, c;
for (var i=0; i<num; i++){
r = t.insertRow(-1);
c = r.insertCell(-1);
c.innerHTML = 'New row ' + i;
}
}

function deleteRow(tableID, rowIndex){
var t = document.getElementById(tableID);
if (rowIndex < t.rows.length){
t.deleteRow(rowIndex);
} else {
alert('Can\'t delete row ' + rowIndex
+ ' as there are only ' + t.rows.length
+ ' in the table');
}
}

</script>

<form action=""><div>
<label for="i0">Rows to add or index to delete<input type="text"
id="i0" name="num" value="1"></label><br>
<input type="button" value="Add rows"
onclick="addRows('xx', this.form.num.value)">
<input type="button" value="Delete row"
onclick="deleteRow('xx', this.form.num.value)">
</div></form>
<table id="xx">
<tr><td>original row
</table>
 
S

Steve

hi and thanks for replyin
just like you said i cannot delete a row after inserting it
or more specific it is delete it but if i hover over the first cell in
any of the remaining rows i get this error .
fortunately i solved the issue with just a single line ,irrelevant in
fact, of code
imagine that IE huh!
i just added
row_to_delete.innerText=""
just before the delete row line and tada!! it's gone
now i dunno how this could be interpreted or whta this stupid line's
effect was over IE but it's IE right !
i hope this helps people who encounter the same problem
thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top