Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2007, 06:49 PM   PM User | #1
Garath531
New Coder

 
Join Date: Mar 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Garath531 is an unknown quantity at this point
"Null" is null or not an object error

I'm using this code.
Code:
<script type='text/javascript'>
var forum = 2
function request() {
if (window.XMLHttpRequest ) { return new XMLHttpRequest(); }
else if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
return false;
}
}
}
}
if(location.href.match(/showforum=/i) && !location.href.match("showforum=" + forum)) {
var tr = document.getElementsByTagName('tr')
for(k=0;k<tr.length;k++) {
if(tr[k].innerHTML.match(/topic title/gi) && tr[k].innerHTML.match(/replies/gi)) {
var table = tr[k].parentNode
var tr2 = table.getElementsByTagName('tr')
for(z=0;z<tr2.length;z++) {
if(tr2[z].innerHTML.match(/topic title/gi)) {
var req = request();
var theLoc = location.href.split("?")[0]
req.open("GET", theLoc + "?showforum=" + forum)
req.onreadystatechange = function() {
if(req.readyState == 4) {
var text = req.responseText
document.getElementsByTagName('body')[0].innerHTML += "<div id='theAnnounce' style='display: none;'>" + text + "</div>"
var newRow = table.insertRow(z+1)
var newCell = newRow.insertCell(-1)
with(newCell) {
className = "darkrow1"
innerHTML = "&nbsp;"
}
}
}
req.send(null)
}
}
}
}
}
</script>
and it keeps giving that error (see topic title) on line 397.
Line 397 is this line.
Code:
var newCell = newRow.insertCell(-1)
I can't figure out what's wrong with it. Can anyone help me?
Garath531 is offline   Reply With Quote
Old 07-26-2007, 12:24 AM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
what is with the -1?

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 07-26-2007, 01:43 AM   PM User | #3
Garath531
New Coder

 
Join Date: Mar 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Garath531 is an unknown quantity at this point
That just means that the new cell will appear at the end of the row. It's the same thing as
Code:
insertCell()
Garath531 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:27 AM.


Advertisement
Log in to turn off these ads.