473,498 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insertRow madness

Hi, and help for a novice trying to get some data dynamically into
tables. I did a small proof of concept page which works fine in IE6 and
Mozilla. Using code such as this:

tbody = document.getElementById('tb');
thead = document.getElementById('header');

tr = thead.insertRow(-1);
td = document.createElement('th');
tr.appendChild(td);

/* start building data here */

[...]

All is well. I paste essentially the same code with subsequent
modifications below this point into a more complex page and it breaks on
IE6 with a 'null is null and not an object' error, regardless of how I
play with it. It breaks at the insertRow statement. I've tried going to
createElement in lieu of insertRow and it breaks in exactly the same
place. No matter what I change. I've tried inserting into the table
itself, thead, and tbody. All get a null object. And yet the original
page works fine, with nearly identical code! Ouch, my brain hurts.

The test pages are:

http://burgiss.net/work/table.html (works fine)
http://burgiss.net/work/pricelist.html (breaks)

Any help is appreciated.

--
Hal Burgiss

Jan 9 '06 #1
8 3453
Hal Burgiss wrote:
Hi, and help for a novice trying to get some data dynamically into
tables. I did a small proof of concept page which works fine in IE6 and
Mozilla. Using code such as this:

tbody = document.getElementById('tb');
thead = document.getElementById('header');

tr = thead.insertRow(-1);
td = document.createElement('th');
tr.appendChild(td);

/* start building data here */

[...]

All is well. I paste essentially the same code with subsequent
modifications below this point into a more complex page and it breaks on
IE6 with a 'null is null and not an object' error, regardless of how I
play with it. It breaks at the insertRow statement. I've tried going to
createElement in lieu of insertRow and it breaks in exactly the same
place. No matter what I change. I've tried inserting into the table
itself, thead, and tbody. All get a null object. And yet the original
page works fine, with nearly identical code! Ouch, my brain hurts.

The test pages are:

http://burgiss.net/work/table.html (works fine)
http://burgiss.net/work/pricelist.html (breaks)

Any help is appreciated.


Most probably because you have already created thead as a global
variable in drawTable() before makeTable() is called.

Make it local in drawTable() and see what happens.

--
Rob
Jan 9 '06 #2
On Mon, 09 Jan 2006 04:14:09 GMT, RobG <rg***@iinet.net.au> wrote:
Any help is appreciated.
Most probably because you have already created thead as a global
variable in drawTable() before makeTable() is called.
Wow, thanks. Looked at it for two hours but did not see that.
Make it local in drawTable() and see what happens.


Sadly, making it a local has not helped yet. I even took out
drawTable() completely and get that error just with makeTable().

Thanks for the help!!

--
Hal Burgiss

Jan 9 '06 #3
Hal Burgiss wrote:
On Mon, 09 Jan 2006 04:14:09 GMT, RobG <rg***@iinet.net.au> wrote:

Any help is appreciated.


Most probably because you have already created thead as a global
variable in drawTable() before makeTable() is called.

Wow, thanks. Looked at it for two hours but did not see that.

Make it local in drawTable() and see what happens.

Sadly, making it a local has not helped yet. I even took out
drawTable() completely and get that error just with makeTable().


Ok, cop this. Comment out the line:

document.getElementById('title').innerHTML = my_title;
and see what happens... :-x

--
Rob
Jan 9 '06 #4
RobG wrote:
[...]

Ok, cop this. Comment out the line:

document.getElementById('title').innerHTML = my_title;
and see what happens... :-x


From the MSDN innerHTML reference:

"The property is read/write for all objects except the following, for
which it is read-only: COL, COLGROUP, FRAMESET, HTML, STYLE, TABLE,
TBODY, TFOOT, THEAD, TITLE, TR. The property has no default value.

...

"You can change the value of the title element using the
document.title property."

<URL:http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp>

Somewhat bizarre side-effect, eh? ;-p

--
Rob
Jan 9 '06 #5
On Mon, 09 Jan 2006 05:18:21 GMT, RobG <rg***@iinet.net.au> wrote:

Ok, cop this. Comment out the line:

document.getElementById('title').innerHTML = my_title;
and see what happens... :-x


Hey, wow that was it!!! Amazing. Mucho gracias! I feel a tremendous
weight has been lifted :0

--
Hal Burgiss

Jan 9 '06 #6
On Mon, 09 Jan 2006 05:24:28 GMT, RobG <rg***@iinet.net.au> wrote:

"You can change the value of the title element using the
document.title property."

Somewhat bizarre side-effect, eh? ;-p


Amen. Now just how did you figure that out?

--
Hal Burgiss

Jan 9 '06 #7
On 9 Jan 2006 06:49:52 -0500, Hal Burgiss <ha*@burgiss.net> wrote:

Hey, wow that was it!!! Amazing. Mucho gracias! I feel a tremendous
weight has been lifted :0


Even stranger (at least to me), "title" was the id of an h2 element.
Chaning the id to "foo" has the same effect. Wierd. Thanks again though.

--
Hal Burgiss

Jan 9 '06 #8
Hal Burgiss wrote:
On Mon, 09 Jan 2006 05:24:28 GMT, RobG <rg***@iinet.net.au> wrote:
"You can change the value of the title element using the
document.title property."

Somewhat bizarre side-effect, eh? ;-p

Amen. Now just how did you figure that out?


thead was an object, but totally bereft of properties. I kept
checking to see when it finally had an ID property.

Remove slabs of stuff until properties appear, then add stuff back
slowly until they're gone again. First I removed all the lines of
makeTable() after the offending line, then the content of the init()
function which gave a clue - fortunately there were only about 6 lines!

No wonder prototyping/RAD is the only way to do web applications -
write a line of code, test everything. Write another line of code,
test everything...
--
Rob
Jan 9 '06 #9

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

Similar topics

3
17924
by: Marco Alting | last post by:
Hi I'm currently developing a form with a dynamic table. initially the table is populated with data and at the end of each row there are two buttons: addLevel and addItem. Each button creates a...
3
16179
by: milkyway | last post by:
Hello, I am working with an old Java Script code and have found the following but after putting in alerts I have found that insertRow doesn't work. What is the problem? TIA function...
1
3152
by: putty | last post by:
I found a few posts of people asking about insertCell()/insertRow() not working in IE6 SP2, and a few others about getting "null is null or not an object" errors, but no one posted a solution...
2
9509
by: Howard Jess | last post by:
CLJ -- I've searched the newsgroup and FAQ for info on insertRow(), but didn't see this reported. It seems that Internet Explorer doesn't respond correctly to either insertRow() or...
1
2848
by: Christopher Berg | last post by:
hi. is there a way to add an id='...' tag to a table row when using the javascript insertRow() ? i wish to be able to manipulate this row later if i need to using that identifier (eg to toggle...
1
15763
by: raju78.k | last post by:
Hi, I have a problem with FireFox. I have written a function to Add rows without submiting the form. This function works fine in IE, but not in FireFox. The function is : function...
1
2592
by: MoProtein | last post by:
I created a row using insertRow: r = tbl.insertRow(); and I want to be able to add an onclick handle to that row. Does any one know how to do this? BTW I've tried
1
2492
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to...
3
3208
by: DL | last post by:
Here's the thing, I have this HTML Table, that has multile rows already, each has an ID, one of them at the bottom section has id of "SaveData", new TRs are dynamically created upon user...
0
7126
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
7005
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
7168
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
7381
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...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4916
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...
0
4595
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...
0
3096
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...
0
293
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...

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.