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

Writing someting in a table cell through Javascript

P: n/a
Hi!

Could anybody help me guide how to write something in between <td></
tdtags. When I try to write through document.write, it wipes the
whole table and writes on to a blank document, but when I try with
document.getElementById("respective id given by me").write, it gives
Error on page.

I'm bit puzzled. Can anyone of you help me.

Thanks in advance
Vasu
Aug 4 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Vasu wrote:
Could anybody help me guide how to write something in between <td></
tdtags.

Get a reference to the table cell object e.g. with
var cell = document.getElementById('cellId');
then append text with
cell.appendChild(document.createTextNode('foo'));
If you want to insert HTML then you can use the innerHTML property e.g.
cell.innerHTML = '<b>foo</b>';

Both approaches are not specific to td elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 4 '08 #2

P: n/a
On Aug 4, 3:55*pm, Martin Honnen <mahotr...@yahoo.dewrote:
Vasu wrote:
Could anybody help me guide how to write something in between <td></
tdtags.

Get a reference to the table cell object e.g. with
* *var cell = document.getElementById('cellId');
then append text with
* *cell.appendChild(document.createTextNode('foo'));
If you want to insert HTML then you can use the innerHTML property e.g.
* *cell.innerHTML = '<b>foo</b>';

Both approaches are not specific to td elements.

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
Hi Martin!

Thank you very much! I tried and it's working.

Vasu
Aug 4 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.