Rewrite/replace table

S

Søren M. Olesen

Hi

What's the best/easiest/fastest way to rewrite a table in javascript...

I've tried something like:

var newgrid=document.createElement("table");
//add some rows and cells
var grid=getElementById("table1");
grid.innerHTML=newgrid.innerHTML;

however the last line gives me a runtime error, so I expect it not allowed
to change the innerHTML this way....

Any suggestions would be greatly appreciated.

TIA

Søren
 
T

Thomas 'PointedEars' Lahn

Søren M. Olesen said:
What's the best/easiest/fastest way to rewrite a table in javascript...

I've tried something like:

var newgrid=document.createElement("table");
//add some rows and cells
var grid=getElementById("table1");

The Global Object does not have a built-in or host-defined `getElementById'
method. It is a method of the object that can be referred to with
`document' instead.
grid.innerHTML=newgrid.innerHTML;

In contrast to the rest of your code, `innerHTML' is completely proprietary.
Do not expect consistent results.
however the last line gives me a runtime error, so I expect it not
allowed to change the innerHTML this way....

Any suggestions would be greatly appreciated.

Read the FAQ before you post: <URL:http://jibbering.com/faq/>


PointedEars

P.S.: Please declare your character encoding. <URL:http://insideoe.com/>
 
M

marss

Søren M. Olesen said:
Hi

What's the best/easiest/fastest way to rewrite a table in javascript...

I've tried something like:

var newgrid=document.createElement("table");
//add some rows and cells
var grid=getElementById("table1");
grid.innerHTML=newgrid.innerHTML;

Replace grid entirely:
grid.parentNode.replaceChild(newgrid, grid);
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top