title: How do I link an "onClick" event to a javascript file?
body: <p>I have a button with an <code>onclick</code> event. </p>
  
  <p>My javascript for the button is not in the HTML document, but I linked it to the document with <code>&lt;script src="example.js"&gt;&lt;/script&gt;</code>. How do I make the "onclick" event link to my javascript file? This is what I tried.</p>
  
  <pre><code>function pasuser(form) {
      if (form.id.value=="user") { 
          if (form.pass.value=="password") {              
              location="example.html" 
          } else {
              alert("Invalid Password")
          }
      } else {
              alert("Invalid UserID")
      }
  }
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;NATUREBOWL- LOGIN&lt;/title&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
          &lt;link rel="shortcut icon" href="favicon.ico"/&gt; 
  
      &lt;script src="loginform.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
          &lt;p&gt;Log in to Conitinue&lt;/p&gt;
          &lt;form name="login"&gt;&lt;p&gt;username    &lt;/p&gt;&lt;input name="id" type="text"&gt;
              &lt;br/&gt;
          &lt;p&gt;password&lt;/p&gt;
          &lt;input name="pass" type="password"&gt;
              &lt;center&gt;
                  &lt;input type="button" value="Login" onClick="login.js"&gt;
              &lt;/center&gt;
  &lt;/center&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>PS-</strong> The <code>function pasuser(form)</code>code is login.js.</p>
  
  <p><strong>PPS-</strong> Sorry if my question is a little vague, I had trouble describing it. Just tell me and I can clear up something or delete this question.</p>