Is there a piece of Javascript that would stop a form submit button from carrying out a function
I am using the CodeIgniter framework which uses MVC pattern.
So when you click the button it calls a controller function which then calls a model function etc.
I tried using various things in Javascript including go back, history go back. Is there anything that will stop any event happening?
Here is my 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");
}
}
It still continues to do the function if I say "Cancel". Is there any way to stop the browser?
This is my php code:
//js = is a variable which stores the javascript code
echo form_submit('view','View', $js);
This creates html output like so:
<input type="submit" onclick="confirmation()" value="View" name="view">