Home News Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | javascript null error


You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion

javascript null error
Reply
 
Thread Tools
Old 04-08-2008, 13:50   #1
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,686
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
javascript null error

Hello peeps,

Yeasterday I posted about my near identical ubuntu servers and a strange charecter encoding problem.. well today I am having a javascript error that occurs on my live server and not on the local server... everything works fine on the local server, but on the remote server it falls over and Firebug reports the following:

Code:
document.getElementById("modelId") is null
the code that is returning this is:

Code:
var modelId = document.getElementById('modelId').value;
so i tried this:

Code:
	if (document.getElementById('modelId').value == null) {
		var modelId = 1
	}else{
		var modelId = document.getElementById('modelId').value;
	}
to no avail...

If anyone could help i would ve really apreciateive!

Last edited by Millay; 04-08-2008 at 13:59. Reason: spelling worked 27 hours without a break
Millay is online now   Reply With Quote
Old 04-08-2008, 13:53   #2
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+ V-Box VM 10MBit
Posts: 10,108
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: javascript null error

But the PHP Pre-processor shouldn't be touching any of the code so I don't see how that would make sense?
__________________
Used to be Zeph - I'm still me though
Peter: Oh my god, Brian, there's a message in my Alphabits. It says, 'Oooooo.'
Brian: Peter, those are Cheerios.
www.elitehealthdistribution.co.uk - www.loonyasylum.net
Graham M is offline   Reply With Quote
Old 04-08-2008, 14:00   #3
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,686
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
Re: javascript null error

Sorry graham excuse my ignorance, but i cant see how php pre-processor is involved??
Millay is online now   Reply With Quote
Old 04-08-2008, 14:00   #4
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+ V-Box VM 10MBit
Posts: 10,108
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: javascript null error

Well you say it works fine on one server and not on another, is the extension of the file .php or?
__________________
Used to be Zeph - I'm still me though
Peter: Oh my god, Brian, there's a message in my Alphabits. It says, 'Oooooo.'
Brian: Peter, those are Cheerios.
www.elitehealthdistribution.co.uk - www.loonyasylum.net
Graham M is offline   Reply With Quote
Old 04-08-2008, 14:05   #5
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,686
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
Re: javascript null error

sorry yes it is a php file so yes it is going through the php preprocessor, which makes me wonder if it has something to do with:

Code:
<script language="javascript">populatevanModels('<?php echo $_POST['modelId']; ?>');</script>
<script language="javascript">setTimeout("populatevanDerivatives('<?php echo $_POST['derivativeId']; ?>')",500);</script>
but the strange thing is only the servers have changed al lthe data and backend databases are the same..
Millay is online now   Reply With Quote
Old 04-08-2008, 14:55   #6
dev
cf.geek
 
Join Date: Jan 2004
Posts: 993
dev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond reputedev has a reputation beyond repute
Re: javascript null error

are you running the js before or after the DOM has fully loaded?
dev is offline   Reply With Quote
Old 04-08-2008, 15:26   #7
A tired software engineer
 
Join Date: Jun 2003
Location: SK10
Posts: 92
OldGeezer will become famous soon enoughOldGeezer will become famous soon enoughOldGeezer will become famous soon enough
Re: javascript null error

Not really a webby person, so I can't help with why it works on one server but not the other, but shouldn't your code work-around be:
Code:
	if (document.getElementById('modelId') == null) {
		var modelId = 1
	}else{
		var modelId = document.getElementById('modelId').value;
	}
OldGeezer is offline   Reply With Quote
Old 04-08-2008, 15:44   #8
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+ V-Box VM 10MBit
Posts: 10,108
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: javascript null error

Also try a semi-colon after var modelId = 1
__________________
Used to be Zeph - I'm still me though
Peter: Oh my god, Brian, there's a message in my Alphabits. It says, 'Oooooo.'
Brian: Peter, those are Cheerios.
www.elitehealthdistribution.co.uk - www.loonyasylum.net
Graham M is offline   Reply With Quote
Old 05-08-2008, 02:27   #9
cf.addict
 
Join Date: Jul 2004
Posts: 295
Paddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation eraPaddy1 has entered a golden reputation era
Re: javascript null error

Check that document itself isn't null...

var modelId = null;

if (document != null) {
if (document.getElementById('modelId') == null) {
modelId = 1;
}else{
modelId = document.getElementById('modelId').value;
}
} else {
modelId = 1;
}
Paddy1 is offline   Reply With Quote
Old 05-08-2008, 07:39   #10
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,686
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
Re: javascript null error

Im almost out of ideas, i tried all your tips, still to know joy.. any ideas greatly apreciated.
Millay is online now   Reply With Quote
Old 05-08-2008, 08:38   #11
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 23
Services: Sky+ V-Box VM 10MBit
Posts: 10,108
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: javascript null error

Could you paste the rest of the code where the modelID input is Millay>
__________________
Used to be Zeph - I'm still me though
Peter: Oh my god, Brian, there's a message in my Alphabits. It says, 'Oooooo.'
Brian: Peter, those are Cheerios.
www.elitehealthdistribution.co.uk - www.loonyasylum.net
Graham M is offline   Reply With Quote
Old 05-08-2008, 21:19   #12
cf.mega poster
 
Millay's Avatar
 
Join Date: Oct 2003
Location: Portsmouth
Age: 30
Posts: 1,686
Millay has reached the bronze age
Millay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze ageMillay has reached the bronze age
Send a message via MSN to Millay Send a message via Yahoo to Millay
Re: javascript null error

Hi graham and everyone else who helped.

I fixed the problem, it was caused by php code, and some ajax stuff.

I feel silly for posting but apreciate all the help..

Its one of those things you work for 20+ hours straight and you cant see the wood for the trees!

---------- Post added at 22:19 ---------- Previous post was at 22:16 ----------

New we should have used a CVS system..
Millay is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 10:29.


Links
Google
 
Web www.cableforum.co.uk


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
Copyright © 2003 - 2008, Cable Forum.
(server1.cableforum.co.uk)