Functions in a .js file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shisou
    New Member
    • Jul 2007
    • 52

    Functions in a .js file

    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.
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    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.

    Code:
    <script src="http://blahblah.com/scripts/someFile.js" language="javascript"   type="text/javascript"></script>

    Comment

    • aswath
      New Member
      • Mar 2008
      • 18

      #3
      Originally posted by pronerd
      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.

      Code:
      <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="javas cript" 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.......
      [CODE=javascript]function call()
      {
      alert("u called me buddy");
      }[/CODE]

      i hope this helps.....
      regards
      Last edited by gits; Mar 27 '08, 08:06 AM. Reason: remember to use CODE TAGS !!!

      Comment

      Working...