473,405 Members | 2,349 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,405 software developers and data experts.

How to insert table row in Mac IE 5.2+

After search in the web,
I found that, insertRow, insertCell, is a bug of Mac IE,
Moreover, <table>, <tbody> seems doesn't support innerHTML,
What is the solution to show dynamic table in Mac IE?

Thank you

Jun 23 '06 #1
3 1838
Cylix wrote:
After search in the web,
I found that, insertRow, insertCell, is a bug of Mac IE,
Moreover, <table>, <tbody> seems doesn't support innerHTML,
What is the solution to show dynamic table in Mac IE?


You can use DOM core methods - use createElement and append it to a
tbody element. The first button below uses getElementById to get a
reference to a tbody element, the second uses a reference to a tr then
uses parentNode to get the tbody.

You don't have to include the tags for a tbody, one will be added anyway
(it's a mandatory element for a table but the tags are optional).
<table border="1">
<tbody id="tbodyA">
<tr id="rowA"><td>fred</td></tr>
</tbody>
</table>

<input type="button" value="Add row 1" onclick="
var b = document.getElementById('tbodyA');
var r = document.createElement('tr');
var c = document.createElement('td');
c.appendChild(document.createTextNode('new Row'));
r.appendChild(c);
b.appendChild(r);
">

<input type="button" value="Add row 2" onclick="
var b = document.getElementById('rowA');
var r = document.createElement('tr');
var c = document.createElement('td');
c.appendChild(document.createTextNode('new Row'));
r.appendChild(c);
b.parentNode.appendChild(r);
">

--
Rob
Jun 23 '06 #2
Thank you so much.
By your example,
all the row is append to the end of the table,
I have tried to use insert before, but I found that they get the same
result.

How can I insert a row at the top of the table?

Thank you!

Jun 26 '06 #3
Cylix wrote:
Thank you so much.
By your example,
all the row is append to the end of the table,
I have tried to use insert before, but I found that they get the same
result.

How can I insert a row at the top of the table?


Use insertBefore with a reference to the first row (it works in other
browsers too):

<script type="text/javascript">

function addTopRow(id)
{
var tableA = document.getElementById(id);
var firstRow = tableA.rows[0];
oTR = document.createElement('tr');
oTD = document.createElement('td');
oTD.appendChild(document.createTextNode('new first row'));
oTR.appendChild(oTD);

// Get reference to tbody using firstRow.parentNode
firstRow.parentNode.insertBefore(oTR, firstRow);
}

</script>
<table id="tableA">
<tr><td>first row</td></tr>
</table>

<input type="button" value="Add top row"
onclick="addTopRow('tableA');">

--
Rob
Jun 26 '06 #4

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

Similar topics

7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
4
by: brent.ryan | last post by:
How do I get the next int value for a column before I do an insert in MY SQL Server 2000? I'm currently using Oracle sequence and doing something like: select seq.nextval from dual; Then I...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
6
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN,...
1
by: EJO | last post by:
with sql 2000 enterprise Trying to build a stored procedure that will take the rows of a parent table, insert them into another table as well as the rows from a child table to insert into...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.