<tr>s are appended to the
<tbody>, and the script works smoothly in all browsers.
No cellIndex in Safari: At the time of writing,
cellIndex is buggy in Safari 2.0; it always returns 0.
W3C DOM table methods and properties
The W3C DOM defines quite a few methods and properties for working with tables. Unfortunately, they suffer from a few browser-incompatibility problems, and even if they work perfectly they're far slower than traditional
appendChild() scripts. I advise you not to use most of these methods and properties.
cellIndex properties may come in useful in some situations. They give the index number of a row in its table (
rowIndex) or a cell in its row (
cellIndex). There's also
sectionRowIndex, which gives the index number of a row in its table section (
innerHTML is badly supported for table elements other than
<td>s. At the time of writing, it's not possible to set the
innerHTML of the
tfoot in Explorer or Safari.
Form fields in Explorer
Generating form fields is hard in Explorer. In theory, it seems simple:
Unfortunately, this code gives errors in Explorer, because the browser cannot handle the newField.type. If we use
setAttribute(), the error message disappears:
Another problem is that generated radio buttons don't work well in Explorer. Although it's possible to generate them through "pure" W3C DOM methods, the browser makes a mess of the name attributes of the radio buttons. Therefore, the generated radio buttons will likely not work as you expect them to.
How Radio Buttons Work: Remember: the user is allowed to check only one radio button in a group, and a group is defined as all radio buttons that share a name attribute. If the name attribute doesn't work correctly, the radio buttons won't work, either.
innerHTML offers a solution:
Now the radio buttons work as expected.