By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

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

P: n/a
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("dyn amiccontent")
var row_to_delete=document.getElementById("tr"+element Id)
for(var
i=row_to_delete.rowIndex+1;i<dynamic_content_table .rows.length;i++)
{
var row=dynamic_content_table.rows[i]
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.rowI ndex) // 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

Sep 14 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Steve" <du*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
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 !
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).

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

Jim Davis

Sep 15 '06 #2

P: n/a
Steve wrote:
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("dyn amiccontent")
var row_to_delete=document.getElementById("tr"+element Id)
for(var
i=row_to_delete.rowIndex+1;i<dynamic_content_table .rows.length;i++)
{
var row=dynamic_content_table.rows[i]
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.rowI ndex) // 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.

--
Rob

Sep 15 '06 #3

P: n/a

Jim Davis wrote:
"Steve" <du*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
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 !

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>

--
Rob

Sep 15 '06 #4

P: n/a
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
RobG wrote:
Jim Davis wrote:
"Steve" <du*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
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 !
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>

--
Rob
Sep 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.