aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes call javascript function from external JS file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "call javascript function from external JS file" Watch "call javascript function from external JS file" New topic
Author

call javascript function from external JS file

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Hi all,

I have three combo boxes and the selection of the 1st one changes the data in the second and thrid combo box. I'm doing this right now, by calling the refresh javascript on the onChange event of the combo box.
But i no longer like the refreshing of the page, so i thought it would be best if i could write a code, to generate the Javascript that i require, and call it on the onChange event of the combo box.
After searching this forum, i got this link which helped me in populating dynamic data through javascript. I'm pasting the code below:



I know how to write a class file to generate the JS file, but i don't know how to call it from the onChange event of the combo box.
In this case, calling the redirect method from the onChange event of the first combo box from the external JS file.
Can plz some one guide me as to how i should call the external JS file from the onChange event of the first combo box to populate data in the second combo box.

Thanxs in advance.
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Hi all,

I have posted the javascript in the external file, and called it
<script lanaguage="javascript" src="dynamic.js">
</script>

and its working absolutely fine...

bye.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
I know how to write a class file to generate the JS file


What does this mean? JavaScript does not have classes, and an external JS file does not need to be generated, it needs to be written and put in a directory from where it can be included in the current page.

how i should call the external JS file


A file is not called, it is included in a page via the script tag. Then you can call any functions that are declared in it.


Ping & DNS - my free Android networking tools app
Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
Hello Ulf Dittmer ,


What does this mean? JavaScript does not have classes, and an external JS file does not need to be generated, it needs to be written and put in a directory from where it can be included in the current page.



I don't want my JS file to be static, that's why i'm going to write a java program that will generate the JS file with the appropriate code and put it in the appropraite directory location.
So i don't want to manually append the Js file, rather i will run my java program to append the JS file.


A file is not called, it is included in a page via the script tag. Then you can call any functions that are declared in it.


Yes, i understood that, and that can be seen in my second reply itself.

Hope i've made myself clear now...!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: call javascript function from external JS file