473,387 Members | 1,669 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,387 software developers and data experts.

"onload" method

JS
I have two functions in an external .js page:

createMenu(sel){
document.write("TEST1");
}

createFirstMenu(sel){
document.write("TEST2");
}
I have another page that includes this javaScript. In this page I use <body
onload="createMenu('sel1');">:

<body onload="createMenu('sel1')">
<form name="sels" method="post" action="?page=jubii">
Kategori:&nbsp;&nbsp;&nbsp;
<select name="sel1" id="sel1" onchange="createMenu('sel1','sel2');">
</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="sel2" id="sel2">
<option value="" selected
-er- Vælg --</option>

</select>
&nbsp;
<input name="search" type="text" id="search">
&nbsp;
<input type="submit" name="Submit" value="Søg">
</form>

"TEST1" get printed when I open this page as expected.

But if I change onload to:
<body onload="createFirstMenu('sel1')">

I don't get "TEST2" printed!
What are the explanation?
Jul 23 '05 #1
2 1508
JS

"JS" <dsa.@asdf.com> skrev i en meddelelse
news:d7**********@news.net.uni-c.dk...
I have two functions in an external .js page:

createMenu(sel){
document.write("TEST1");
}

createFirstMenu(sel){
document.write("TEST2");
}

I tried to switch the order of the two methods:

createFirstMenu(sel){
document.write("TEST2");
}

createMenu(sel){
document.write("TEST1");
}

And now it works! But I don't know why....is it nessecary to write methods
in a strict order?
Jul 23 '05 #2
JS wrote:
createFirstMenu(sel){
document.write("TEST2");
}

createMenu(sel){
document.write("TEST1");
}

And now it works! But I don't know why....is it nessecary to write methods
in a strict order?


No. Your give example works for me (if I add the word "function" before
each function).

You may give us an URL with an example so we may take a look.

Daniel
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TPG | last post by:
I'd like a Javascript function I have written to be invoked whenever *any* new document is been loaded into a particular frame (i.e I don't control the incoming document's BODY tag). Under...
3
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and...
3
by: George Hester | last post by:
Nothing. The applet does what it is supposed to do but onload never fires. Any suggestions what may be the problem here? Thanks. -- George Hester __________________________________
4
by: Viken Karaguesian | last post by:
Hello all, I have a question. I trying to run two Javascripts on my webpage, both of which need a <body onload> command. They are as follows: <body onload="runMe()"> <body...
7
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view):...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
5
by: tuxedo | last post by:
The way the <body onload="something()"works ensures that the complete html document is loaded before something() is executed. Can the same be achieved when placing the onload call in document...
1
Cristian Pinheiro
by: Cristian Pinheiro | last post by:
Hello guys, I was playing with Image Thumbnail Viewer (ITV) and found one problem, see http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm for more details and how it works. Now the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.