NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT (Slightly) Help with PHP/JavaScript Error Resolution?

Rob Marscher rmarscher at beaffinitive.com
Mon Jul 31 16:01:57 EDT 2006


Like Ed says, it could be that the javascript is called before the page 
has finished rendering the element that has the id you're trying to grab.

It also could just be that the id doesn't exist on the page at all.

i.e. if count is set to 6 and there's no div on the page that has it's 
id set to Div6 like this:
<div id="Div6"> stuff in here </div>

Then
document.getElementById("Div" + count)
doesn't find anything.

The full line is probably something like
document.getElementById('Div" + count).style.display = 'none';

The extra .style.display means it is trying to access that property of 
what document.getElementById('Div" + count) is returning.  It's not 
finding an element with that id which is why the error says that it 
doesn't have any properties.

Are you the one adding the id's to the divs in your html or php?  If 
not, it might be getting automatically done by your javascript and 
perhaps you've manually added an id to a div and is conflicting with the 
javascript's auto handling of it?  Just taking stabs in the dark here... 
  Might be able to help more if I saw the code.

<aside>Anyone else notice that example link actually goes to porn site? 
Too funny...</aside>

-Rob


R. Mariotti wrote:
> Sorry - I know this is most likely a js issue but it seems to be 
> occurring in only ONE of my PHP programs so I thought I would ask here 
> because of the VAST amount of insight and expertise available...
> 
> I am trying desperately to incorporate a free js routine that hides a 
> DIV and then redisplays it when asked using DHTML. (too, too many 
> technologies!!!)
> 
> This is a canned routine included with a <script src...> statement in 
> the appropriate place.  When I try to run the program my js console 
> shows the following error ONLY in this ONE PHP program.  SO, what might 
> I be doing within this program to cause this js error? (rhetorical)
> 
> Can someone perhaps "explain" what this error is trying to tell me and 
> how my PHP program can cause it???
> 
> Error: document.getElementById("Div" + count) has no properties
> Source File: http://www1.xxxxxxxxxxx.com/openpopups.js
> Line: 320
> 
> Any assistance, pointers, redirection, etc will be G-R-E-A-T-L-Y 
> appreciated!
> 
> Thank you,
> 
> Bob
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
> 
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
> 



More information about the talk mailing list