473,799 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ie6 Insert Row at specific Row Index of Table

Can someone show me how to insert a row at any given row index of an
already created table? It only has to work in IE6 (used on intranet at
work).

Specifically, if a table is 20 rows in total (thought his will vary),
and someone wants to insert a new row at row 5, i need for one row to
be added, and each of the rows from 5-20 to be "cloned" to 6-21.

The contents of row 5 may vary as well; it is not a straight copy of an
exisiting row.

I have seen something that did this very thing, but it used innerHTML,
and I have read this is inavisable for tables.

Thanks,
Ann

Feb 5 '06
28 18542
Ian Collins wrote:
RobG wrote:
3) on the first attempt to insert a row tBody section is created and
new row is added as a child if it (namely emulation of IE behavior).


Rubbish. The tbody is created when the HTML source for the table is
parsed, whether the tags are there or not because that is what the
HTML 4 spec says should happen. It is not created as a result of
using insertRow.

Not rubbish, it depends on the context. If you are building a table in
script, the tbody will be added when you add the first row, try:


The bit that is rubbish is the phrase 'emulation of IE behavior' - it is
conforming to the W3 DOM 2 specification.

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-39872903>
Your point is valid, but the discussion wasn't about building a table
with script, it was about inserting a new row into an existing table and
in that context the tbody already exists.

It is also interesting to compare the behaviour of different browsers
when adding a row using the HTMLTableElemen t::insertRow method and the
Node::appendChi ld method.

insertRow is 'safer' as in conforming browsers it automatically handles
the tbody issue. When adding rows with appendChild, not all browsers
will handle adding the row to a table (e.g. IE), they require the row to
be explicitly added to a tbody (or other table section). appendChild
might be more widely supported and is a reasonable first fallback.

If you have a table with more than one section (say with a thead, tfoot
or multiple tbodys) then you should get a reference to the correct table
section anyway to add the row - otherwise insertRow will just add the
row to the last tbody element.

[...]
--
Rob
Feb 7 '06 #21
Gérard Talbot wrote:
Ian Collins wrote :
which browsers don't work as expected?

InsertRow() is not working accordingly
http://www.gtalbot.org/BrowserBugsSe...otWorking.html


If you add the tbody to the table *before* using insertRow, it works
fine (or add the rows to the table instead...).
[...]
--
Rob
Feb 7 '06 #22
RobG wrote :
Gérard Talbot wrote:
Ian Collins wrote :
which browsers don't work as expected?

InsertRow() is not working accordingly
http://www.gtalbot.org/BrowserBugsSe...otWorking.html

If you add the tbody to the table *before* using insertRow, it works
fine (or add the rows to the table instead...).


Yep. It works. Amazing.

I still think MSIE 6 and MSIE 7 beta 2 are buggy on this though.

Gérard
--
remove blah to email me
Feb 7 '06 #23
RobG wrote:

The bit that is rubbish is the phrase 'emulation of IE behavior' - it is
conforming to the W3 DOM 2 specification.
OK.
insertRow is 'safer' as in conforming browsers it automatically handles
the tbody issue. When adding rows with appendChild, not all browsers
will handle adding the row to a table (e.g. IE), they require the row to
be explicitly added to a tbody (or other table section). appendChild
might be more widely supported and is a reasonable first fallback.
OK.
If you have a table with more than one section (say with a thead, tfoot
or multiple tbodys) then you should get a reference to the correct table
section anyway to add the row - otherwise insertRow will just add the
row to the last tbody element.

Doesn't it (insertRow) add the row to the section containing the
previous row?
--
Ian Collins.
Feb 7 '06 #24
Ian Collins wrote:
Thomas 'PointedEars' Lahn wrote:
Scripting, especially DOM scripting, operating from within and on not
Valid markup has been proven to be inherently unreliable. Examples/demos
should be Valid or they are next to useless.


How can I show IE adding the missing element if I include it in the
markup?


For example by counting the rows of the table afterwards.
PointedEars
Feb 7 '06 #25
Ian Collins wrote:
RobG wrote:
If you have a table with more than one section (say with a thead, tfoot
or multiple tbodys) then you should get a reference to the correct table
section anyway to add the row - otherwise insertRow will just add the
row to the last tbody element.


Doesn't it (insertRow) add the row to the section containing the
previous row?


At least it is specified so.

<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-39872903>
PointedEars
Feb 7 '06 #26
Ian Collins wrote:
RobG wrote: [...]
If you have a table with more than one section (say with a thead,
tfoot or multiple tbodys) then you should get a reference to the
correct table section anyway to add the row - otherwise insertRow will
just add the row to the last tbody element.

Doesn't it (insertRow) add the row to the section containing the
previous row?


I think you mean at the nominated table row index - so yes. I was
playing with -1 so it always went at the end.

The TR's rowIndex property is in respect to the table as a whole, but
when inserting in a section (e.g. objTbody.insert Row(i)), the index is
in relation to the section.

--
Rob
Feb 7 '06 #27
Thomas 'PointedEars' Lahn wrote:
Ian Collins wrote:

Thomas 'PointedEars' Lahn wrote:
Scripting, especially DOM scripting, operating from within and on not
Valid markup has been proven to be inherently unreliable. Examples/demos
should be Valid or they are next to useless.


How can I show IE adding the missing element if I include it in the
markup?

For example by counting the rows of the table afterwards.

Not a lot of use when the missing element is a tbody....

--
Ian Collins.
Feb 7 '06 #28
Ian Collins wrote:
Thomas 'PointedEars' Lahn wrote:
Ian Collins wrote:
Thomas 'PointedEars' Lahn wrote:
Scripting, especially DOM scripting, operating from within and on not
Valid markup has been proven to be inherently unreliable.
Examples/demos should be Valid or they are next to useless.
How can I show IE adding the missing element if I include it in the
markup?

For example by counting the rows of the table afterwards.

Not a lot of use when the missing element is a tbody....


Actually, the `tbody' element is never missing if there is a `table'
element. It is its tags that are missing since they are both optional,
and, depending on the DOM, the respective element object in the document
tree that is therefore missing.

To detect if this object was included in the document tree only because
of calling insertRow() or another table-related DOM method, it would be
sufficient to call getElementsByTa gName("tbody") for the HTMLTableElemen t
object before and after calling the DOM method, and examining its
properties (`length', for example).
PointedEars
Feb 7 '06 #29

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

Similar topics

1
1540
by: Doron | last post by:
is there a setting that will ebnable uniform extent allocation upon creation of index/table by default ? if there isn't any default setting can you code it in? thanks, Doron
1
6072
by: Jay | last post by:
Hi I have a huge table with over 100million records and on regular basis ineed to delete nearly a million records and insert a million records. Currently I delete indexes before going through the process and recreate the indexes which takes a very very long time. IS there a way to disable indexes and re enable them after doing insert and delete by reindexing or anything of that sort? OR Is there an approach to append two tables with...
0
6893
by: crypto_solid via AccessMonster.com | last post by:
I have been using a SQL database with a VB5 frontend for about 5 years. Works well. Unfortunately I don't have access to the source code. I was tasked with implementing a "job entry" application that will allow a restricted list of users to enter jobs in the database. We do not want these users to be able to access all the data. I created an application in Access 2002 that performs this function seemingly quite well. However we now...
1
1553
by: Daniele | last post by:
Hi, how is it possible to create a full-text index table? Thanks, Daniele
1
1296
by: Bill Nguyen | last post by:
Below is the content of a textbox after data was captured from a barcode scanner. Instead of saving it into a text file and process later, I would like to be able to read the items (delimited by <CR>) and insert into a table. Please help show me an efficient way to do it. Thanks Bill
1
4564
by: technocraze | last post by:
Hi guys, I am having trouble resolving this error. Below mentioned is my code and implmentation. MS Acess is my front end and sql server is my backend. What i want to achieve is to be able to insert StudentId in the table matching the values chosen in the combo boxes and listboxes. This sound more like searching the table to insert StudentId matching the criterias. I have set the necessary configuration for ODBC connection (File...
7
14464
gcoaster
by: gcoaster | last post by:
Hello Gurus, I am stuck! this will be easy I am sure for you. I have a Text Box where I type In a name. I am trying to get that value to insert into another table when I TAB to the next field. Most of the INSERT code examples I find deal with multiple VALUES. could you point me in the right direction?
3
3175
by: grumpygit | last post by:
Hi. I am trying to get the columns in the navigation/index table to all be the same width on the page in link below. Code in attached .zip file Any advice would be greatly appreciated as I am a complete novice when it comes to CSS. Thanks. GG http://jinx.byethost13.com/template.php
1
1665
by: chennaibala | last post by:
hi frds... in my hiden textbox.i have following values... robert|true|true|false|arun|true|false|true|anu|true|true|false| i want to splits in to token and insert in mysql table in following manner namefield writefiled readfield speakfield robert true true false arun true false true anu true true false
1
2133
pradeepjain
by: pradeepjain | last post by:
Hii guys, I have 2 tables in which data exists of a same user like his table1:login details and table2: his further details . I have a form where in his both login and rest of details are collected. When i submit the form it needs to insert data in both the tables . Which is the best method to do it . insert into 1st table and if successful then insert into 2nd table ?
0
10485
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.