title: I have a form with the submit button linked to javascript function but nothing is happening when I click the submit button
body: <p>I'm trying to make a form which when I click the submit button will send the information from the form fields to a javascript function and then show the results to the user.  I've made something like this before that's very similar and works fine, but for some reason this isn't doing anything when I click submit. I must have missed something. Here's the code:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8" &gt;
      &lt;title&gt;Javascript Form&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form id="formID" name="myform" action="" method="get"&gt;
  
      Customer Name:
      &lt;input type="text" name="names" value=""&gt;
      &lt;br/&gt;
  
      Street Address:
      &lt;input type="text" name="street" value=""&gt;
      &lt;br/&gt;
  
      City:
      &lt;input type="text" name="city" value=""&gt;
      &lt;br/&gt;
  
      State:
      &lt;input type="text" name="state" value=""&gt;
      &lt;br/&gt;
  
      Zip Code:
      &lt;input type="text" name="zip" value=""&gt;
      &lt;br/&gt;
  
      Beginning Odometer Reading:
      &lt;input type="text" name="beginO" value=""&gt;
      &lt;br/&gt;
  
      Ending Odometer Reading:
      &lt;input type="text" name="edinO" value=""&gt;
      &lt;br/&gt;
  
      Number of Days Car was Used:
      &lt;input type="text" name="days" value=""&gt;
      &lt;br/&gt;
  
      &lt;input type="button" name="button" value="Submit" onClick="car(this.form)"&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
      function car(form) {
          var names = form.names.value;
          var street = form.street.value;
          var city = form.city.value;
          var state = form.state.value;
          var zip = form.zip.value;
          var beginO = form.beginO.value;
          var endO = form.endO.value;
          var days = form.days.value;
  
          var miles = endO - beginO;
          var charge = days * 15 + miles * 0.12;
  
          alert("Miles driven: " + miles + ". Charge: " + charge + ". Name: " + names + ". Address : " + street + " , " + city + " " + state + " " + zip + ". ");
      }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>