473,320 Members | 2,110 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,320 software developers and data experts.

onLoad() event - obj undefined error

17
I need to apply an onLoad() event to call the function displayed below.
I tried <body bgcolor="#B3FFB3" onLoad="display(obj)"> and it comes up with an error message of obj undefined.
My question is how do I define obj?
Thanks for any help.


Expand|Select|Wrap|Line Numbers
  1. function display(obj,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10) {
  2. txt = obj.options[obj.selectedIndex].value;
  3. document.getElementById(id1).style.display = 'block';
  4. document.getElementById(id2).style.display = 'block';
  5. document.getElementById(id3).style.display = 'block';
  6. document.getElementById(id4).style.display = 'block';
  7. document.getElementById(id5).style.display = 'block';
  8. document.getElementById(id6).style.display = 'block';
  9. document.getElementById(id7).style.display = 'block';
  10. document.getElementById(id8).style.display = 'block';
  11. document.getElementById(id9).style.display = 'block';
  12. document.getElementById(id10).style.display = 'block';
  13.  
  14. if ( txt.match(id1) ) {
  15. document.getElementById(id1).style.display = 'block';
  16. document.getElementById(id2).style.display = 'none';
  17. document.getElementById(id3).style.display = 'none';
  18. document.getElementById(id4).style.display = 'none';
  19. document.getElementById(id5).style.display = 'none';
  20. document.getElementById(id6).style.display = 'none';
  21. document.getElementById(id7).style.display = 'none';
  22. document.getElementById(id8).style.display = 'none';
  23. document.getElementById(id9).style.display = 'none';
  24. document.getElementById(id10).style.display = 'none';
  25.  
  26. }
  27. if ( txt.match(id2) ) {..... Code goes on to match other id 3-10
Feb 14 '08 #1
3 2341
acoder
16,027 Expert Mod 8TB
You need to set obj to something, e.g. var obj = document.getElementById("obj").
Feb 14 '08 #2
Alexio
17
It has been awhile since I was able to get back to this project.
Thanks again for your help. You have been able to really help me out!
Feb 20 '08 #3
acoder
16,027 Expert Mod 8TB
No problem. Glad to hear that you got it working.
Feb 21 '08 #4

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

Similar topics

3
by: Da Costa Gomez | last post by:
Hi all, I've been eluded the last couple of *days* on the onload mystery within the frame and function context. Problem is as follows: - frameset with two frames. One called scripts and the...
2
by: andy johnson | last post by:
I made the mistake of "upgrading" to IE6.0 on my windoze 98 laptop. I really wish bill gates would die in a horribly painful accident. Anyway, after much grief, I downloaded Opera and saw true...
5
by: Mike Hnatt | last post by:
I'd like the focus to be on "mycontrol" when the page is first loaded. I'm getting an undefined error and am assuming that I can't do this in the body ONLOAD event because the control is not yet...
4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
10
by: berg | last post by:
I'm trying to use the onload event to load a series of urls. What I find is that the onload function is only called one time no matter how large the array. Here is the onload function. var...
9
by: bmgz | last post by:
I need to execute a JavaScript function "onload". The only problem is I don not have access to the <body> tag as it is a part of the standard page-header include (a separate file). How could I have...
2
by: Martin Honnen | last post by:
I was playing around with canvas support in recent Safari, Mozilla and Opera (only version 9 preview) but run into issues with Safari related to the very old DOM Level 0 Image object for preloading...
3
by: jon | last post by:
Hello, I've had long standing code that runs in IE, that I'm testing with firefox unsuccessfully now. The problem seems to be that images that I dynamically create don't fire their onload event...
20
by: Mark Anderson | last post by:
Hi, I have this in an external JS library: ///////////////////////// function addMyEvent(){ var obj; if(document.attachEvent) { obj = document.getElementsByTagName('img'); for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.