title: Javascript confirm delete - if no do not submit form? Codeigniter
body: <p>Is there a piece of Javascript that would stop a form submit button from carrying out a function</p>
  
  <p>I am using the CodeIgniter framework which uses MVC pattern. </p>
  
  <p>So when you click the button it calls a controller function which then calls a model function etc.</p>
  
  <p>I tried using various things in Javascript including go back, history go back. Is there anything that will stop any event happening?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>function confirmation() {
      var answer = confirm("Delete Record?")
      if (answer)
      {
  
      }
      else
      {       //reloads current page - however it still continues to function
          window.redirect("http://localhost/midas/index.php/control_panel/user_records");
      }
  }
  </code></pre>
  
  <p>It still continues to do the function if I say "Cancel". Is there any way to stop the browser?</p>
  
  <p>This is my php code:</p>
  
  <pre><code>//js = is a variable which stores the javascript code
  echo form_submit('view','View', $js);
  </code></pre>
  
  <p>This creates html output like so:</p>
  
  <pre><code>&lt;input type="submit" onclick="confirmation()" value="View" name="view"&gt;
  </code></pre>