469,348 Members | 1,261 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,348 developers. It's quick & easy.

baffling getElementById() has no properties error


In both IE7 and FF2(using firebug) I get the same error.

I have a page that displays work contacts' details within a
<DIV class = "contactBase" >.

The div has a header area
<div id="contactHeader" class="client" >
in which is displayed the contact's name.

Within this header area div I also want to display in smaller font
the name of the person who listed this contact.

I want to do this in <div id="contactLister" .

Thus we have:

<DIV class = "contactBase" >
<div id="contactHeader" class="client" >
<div id="contactLister" >

</div>
</div>
...
...
</DIV>
The contact is chosen from a <selectelement
(outside of these divs) which calls a
javascript function selectContact().

Within selectContact()
I successfully display the contact name with the line
document.getElementById('contactHeader').innerHTML = contactName;

However when I then try to display the lister with
document.getElementById('contactLister').innerHTML = listerName;

I get the error:
document.getElementById("contactLister") has no properties

I have placed the javascript at the bottom of the <bodybelow all the
html.
In addition I have tried placing the line
document.getElementById('contactLister').innerHTML = listerName;
in a separate function called at the end of selectContact()
but all to no avail.

I would be grateful if someone can tell me what I am doing wrong here.
TIA

N

Mar 30 '07 #1
2 2401
Lee
noddy said:
>

In both IE7 and FF2(using firebug) I get the same error.

I have a page that displays work contacts' details within a
<DIV class = "contactBase" >.

The div has a header area
<div id="contactHeader" class="client" >
in which is displayed the contact's name.

Within this header area div I also want to display in smaller font
the name of the person who listed this contact.

I want to do this in <div id="contactLister" .

Thus we have:

<DIV class = "contactBase" >
<div id="contactHeader" class="client" >
<div id="contactLister" >

</div>
</div>
...
...
</DIV>
The contact is chosen from a <selectelement
(outside of these divs) which calls a
javascript function selectContact().

Within selectContact()
I successfully display the contact name with the line
document.getElementById('contactHeader').innerHTM L= contactName;

However when I then try to display the lister with
document.getElementById('contactLister').innerHTM L= listerName;

I get the error:
document.getElementById("contactLister") has no properties
In your original HTML, contactLister is contained within contactHeader.
When you replace the contents of contactHeader by changing its innerHTML
attribute, you destroy contactLister.
--

Mar 30 '07 #2
On 29 Mar 2007 17:53:51 -0700, Lee <RE**************@cox.netwrote:
>In your original HTML, contactLister is contained within contactHeader.
When you replace the contents of contactHeader by changing its innerHTML
attribute, you destroy contactLister.
Thanks - your help is much appreciated.

N
Mar 30 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Robi | last post: by
2 posts views Thread by CharlesA | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.