469,322 Members | 1,559 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,322 developers. It's quick & easy.

Functions in a .js file

52
Hello everyone,

I was wondering how i could call a function in a .js file from my html document. the call is going to come from a onchange event.

Any help will be appreciated.
Mar 26 '08 #1
2 1007
pronerd
392 Expert 256MB
It does not work any differently than calling JS functions that are in the page. You will need to have a script tag on the page pointing to the remote .JS file so the page knows to load the file.

Expand|Select|Wrap|Line Numbers
  1. <script src="http://blahblah.com/scripts/someFile.js" language="javascript"   type="text/javascript"></script>
Mar 26 '08 #2
aswath
18
It does not work any differently than calling JS functions that are in the page. You will need to have a script tag on the page pointing to the remote .JS file so the page knows to load the file.

Expand|Select|Wrap|Line Numbers
  1. <script src="http://blahblah.com/scripts/someFile.js" language="javascript"   type="text/javascript"></script>
[HTML]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript" src="file_name.js">
</script>
</head>
<body>
<form name="form">
<select name="select" onchange="call();">
<option value="hi">hi</option>
<option value="bye">bye</option>
</select>
</form>
</body>
</html>
[/HTML]

u js file as follows.......
Expand|Select|Wrap|Line Numbers
  1. function call()
  2. {
  3.     alert("u called me buddy");
  4. }
i hope this helps.....
regards
Mar 27 '08 #3

Post your reply

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

Similar topics

2 posts views Thread by Erwin Moller | last post: by
7 posts views Thread by Nolan Martin | last post: by
7 posts views Thread by Srini | last post: by
17 posts views Thread by cwdjrxyz | last post: by
4 posts views Thread by John Goche | last post: by
4 posts views Thread by none | last post: by
80 posts views Thread by nicolas.sitbon | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.