471,831 Members | 775 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

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 2450
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
NeoPa
reply views Thread by NeoPa | last post: by
aboka
reply views Thread by aboka | last post: by

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.