473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

document.getElementById has no properties

5
Hello!

I have this script in external file:

Expand|Select|Wrap|Line Numbers
  1. function showL(){
  2.     hideAll();
  3.     document.getElementById('la1').style.visibility='visible';
  4.  
  5. }
  6.  
and I get error on document.getElementById has no properties

Expand|Select|Wrap|Line Numbers
  1. function hideAll(){
  2. document.getElementById('la1').style.visibility='hidden';
  3. document.getElementById('la2').style.visibility='hidden';
  4. document.getElementById('la3').style.visibility='hidden';
  5. document.getElementById('la4').style.visibility='hidden';
  6. }
  7.  
In html I have defined id as follows:

[HTML]<div id="la1">
</div>[/HTML]

anyone can see problem here? Thanx
Sep 7 '07 #1
5 2319
gits
5,390 Expert Mod 4TB
hi ...

do you have all divs with id's in your html? when do you call the function that throws the error? the first time you should call it is onload of your document, not during parse-time of it (while loading) ...

kind regards
Sep 7 '07 #2
Cico1
5
hi ...

do you have all divs with id's in your html? when do you call the function that throws the error? the first time you should call it is onload of your document, not during parse-time of it (while loading) ...

kind regards
yes i do! i first time call this function when user clicks on link...
Sep 7 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

in that case we need to see more of your code ... because the following example is working:

[HTML]
<script>
function showL(){
hideAll();
document.getElementById('la1').style.visibility='v isible';
}

function hideAll(){
document.getElementById('la1').style.visibility='h idden';
document.getElementById('la2').style.visibility='h idden';
document.getElementById('la3').style.visibility='h idden';
document.getElementById('la4').style.visibility='h idden';
}
</script>

<body>
<input type="button" value="click" onclick="showL();"/>
<div id="la1">
test1
</div>
<div id="la2">
test2
</div>
<div id="la3">
test3
</div>
<div id="la4">
test4
</div>
</body>
[/HTML]

you get the error when the user clicks? is there any other method called?

kind regards
Sep 7 '07 #4
Cico1
5
hi ...

in that case we need to see more of your code ... because the following example is working:

[HTML]
<script>
function showL(){
hideAll();
document.getElementById('la1').style.visibility='v isible';
}

function hideAll(){
document.getElementById('la1').style.visibility='h idden';
document.getElementById('la2').style.visibility='h idden';
document.getElementById('la3').style.visibility='h idden';
document.getElementById('la4').style.visibility='h idden';
}
</script>

<body>
<input type="button" value="click" onclick="showL();"/>
<div id="la1">
test1
</div>
<div id="la2">
test2
</div>
<div id="la3">
test3
</div>
<div id="la4">
test4
</div>
</body>
[/HTML]

you get the error when the user clicks? is there any other method called?

kind regards
Yes, I get error, when the user clicks. No, there is no other method called. Do u need more of my html code? Because my only javascript code is listed above...
Sep 7 '07 #5
gits
5,390 Expert Mod 4TB
yes ... please post the html ... so that we may have a closer look on your problem ...

kind regards
Sep 7 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
1
by: mitra4umohit | last post by:
Hi, I am novice user of JavaScript. I have written one jsp with java script as given below. On click on hyperlink "User Link" my FireFox firebug says "document.frm has no properties" code...
4
by: noddy | last post by:
I need to retrieve some notes from a database, allow users to modify them and then return them to the database.I have done this satisfactorily using php.However I would like to do it using AJAX. ...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.