title: HTML Form and Javascript Confirmation
body: <p>I'm having a problem with submitting a form and Javascript confirmation. Basically, the following Javascript is called when the "submit" button is pressed.</p>
  
  <pre><code>function confirmation() {
      var answer = confirm("Are you sure you wish to edit?")
      if (answer)
      {
          window.location = "#editform2";
      }
  }
  </code></pre>
  
  <p>However, when I hit the cancel instead of ok, the Javascript executes correctly, because I watch the address bar and it doesn't update to #editform2. The form, however, still submits. It seems to refresh the page. Here's the relevant parts from the form:</p>
  
  <pre><code>//Form is encoded in PHP
  &lt;form method=\"post\"&gt;
  //Form is in here
  &lt;input type=\"submit\" value=\"Edit\" onclick=\"confirmation()\"&gt;
  </code></pre>
  
  <p>So the form doesn't know where it's going, it just refreshes the page, and the page happens to be the processor as well. So it's processing even though I clicked cancel and the Javascript should keep it on the same page. Besides moving the processing to a different page, what are my solutions?</p>