473,395 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create TBodies Node

Hi all,

I've got a few lines of javascript which works fine with IE, but I
don't know how to adapt the code so it also works on FF:

************************************
// create the table
var ItemTable = document.createElement("TABLE");

// insert a row for the topic
var myTHeadCell = ItemTable.createTHead().insertRow(0).insertCell(0) ;
myTHeadCell.width="100%";
myTHeadCell.innerText="Title";

// insert a row for the instruction
ItemTable.tBodies[0].insertRow(0);
ItemTable.tBodies[0].rows[0].insertCell(0);
ItemTable.tBodies[0].rows[0].cells[0].className="instruction";
ItemTable.tBodies[0].rows[0].cells[0].innerText="instruction/question";
************************************
The code fails when I try to insert the "Instruction"-Row: In FF no
tBodies-Collection exists.

And when I write ItemTable.insertRow(0) instead, the row is added to
the THead.

How do I create a table body?

Thanks, Matthias
Jan 16 '07 #1
1 3656
Matthias Langbein wrote:
I've got a few lines of javascript which works fine with IE, but I
don't know how to adapt the code so it also works on FF:

************************************
// create the table
var ItemTable = document.createElement("TABLE");

// insert a row for the topic
var myTHeadCell = ItemTable.createTHead().insertRow(0).insertCell(0) ;
myTHeadCell.width="100%";
myTHeadCell.innerText="Title";

// insert a row for the instruction
ItemTable.tBodies[0].insertRow(0);
ItemTable.tBodies[0].rows[0].insertCell(0);
ItemTable.tBodies[0].rows[0].cells[0].className="instruction";
ItemTable.tBodies[0].rows[0].cells[0].innerText="instruction/question";
************************************
The code fails when I try to insert the "Instruction"-Row: In FF no
tBodies-Collection exists.

And when I write ItemTable.insertRow(0) instead, the row is added to
the THead.
That is correct according to
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-39872903>.
How do I create a table body?
var tbody = document.createElement('tbody');
then call insertRow on the tbody element object. You will need to
appendChild the tbody to the table then explictly.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Wolfgang Kreuzer | last post by:
Hello all, I have two tables - Projects and ProjectStruct Table Projects contains master records of the projects, ProjectStruct allows to define a project herarchie and contains the fields...
2
by: Mriganka | last post by:
I want to create a hierarchical tree from the array of strings obtained by extracting a jar file.I want to do this using Javascript. For ex, I am having the entries in the array as...
9
by: jab | last post by:
Je veux lier (join) une table qui se trouve dans une database avec une qui se trouve dans une autre database. Les 2 databases sont sur le même serveur en l'occurence DB2/NT 7.2.9. J'ai créé un...
0
by: Shahriar Shamil Uulu | last post by:
Hi All, i have this program, ================================================================= class Node: def __init__(self,name=None,next=None): self.name=name self.next=next def...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
5
by: Philip Nelson | last post by:
I get - db2inst1@dvorak /db2data $ db2 "create database DBTST001 automatic storage yes on /db2data/db2db dbpath on /db2data/db2db" SQL0805N Package "NULLID.SQLE2F0J 0X4141414141654557" was not...
3
by: quiz123 | last post by:
I am solving some old papers to improve my programming skills. I am a beginer to linked list. the question is: Define a C++ functions that create 50 nodes and return the pointer to the first...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
4
by: Michael Munch | last post by:
Hi I want to read the value of af text-field, create dynamic, in a form. Se below a small test-site to do that (but readning fails): I use the function Test_Read for reading the value from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.