Closed Thread Icon

Topic awaiting preservation: Writing to a Table Cell using writeln.. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8313" title="Pages that link to Topic awaiting preservation: Writing to a Table Cell using writeln.. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Writing to a Table Cell using writeln.. <span class="small">(Page 1 of 1)</span>\

 
Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 09-17-2002 02:20

Is writing to a table cell like this possible?

document.all.surveyTable.rows[0].cells[0].innerHTML.writeln("<TR><TD><B>Client-side--</B><BR>");


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-17-2002 03:04

No... only the document supports the write and writeln functions, and when called after the page has finished loading, they overwrite the entire document (and the changes appear when document.close() is called).

You have to fiddle with the innerHTML property (which is a string) directly.

Note that innerHTML is not part of the DOM spec.

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 09-17-2002 14:59

so we're looking at something like

document.all.surveyTable.rows[0].cells[0].innerHTML = "<TR><TD><B>Client-side--</B><BR>";

..or maybe..

document.getElementByID('surveyTable').innerHTML = "<TR><TD><B>Client-side--</B><BR>";
?

{EDIT}
ok, I just tried it as this:
document.getObjElementByID("survey").innerHTML
and it won't work- it says "Object doesn't support this property or method"



Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

[This message has been edited by Petskull (edited 09-17-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-17-2002 15:11

Right. Except you don't need to write the <tr> or <td> tags, since they're on the outside of the TD, and you're editing the *inner* HTML.

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 09-17-2002 15:15

I told ya- it didn't work...

..no matter if the 'getElementByID' points to either the table or the cell..

oh, yeah... and the reason I want the TR and TD tags is because I want to add a new cell under the old one...

{EDIT}
I figured Javascript would be nice to me if I bagged the table row and table cell tags:
document.getElementByID("dacell").innerHTML = "<B>Client-side--</B><BR>";

No dice.


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

[This message has been edited by Petskull (edited 09-17-2002).]

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 09-17-2002 15:44

well, I've got a sweeping declaration for all in the room:

..getElementByID and getElementById are not the same thing...

*Goes to jot that down in the FAQ*


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

« BackwardsOnwards »

Show Forum Drop Down Menu