Reputation: 45
I have this code currently:
<form id="form1" name="form1" method="post" action=""
onclick="return confirm('This is irreversible. Are you sure?');">
<input type="hidden" name="act" value="run">
<input id="btnDelete" name="btnDelete" type="button" value="Delete Selected"/>
</form>
<?php
if (isset($_POST['act']))
{
echo "<script>alert(\"sup\");</script>";
}
?>
The alert is to check if it will run when i press "ok". It currently does not. I'm at my wits end, especially since I'm pretty much a noob at Javascript. If anyone can help it'll be greatly appreciated!
Upvotes: 1
Views: 2950
Reputation: 2598
Give a type="submit"
to your submit button, and a onsubmit
event to your form
:
<form id="form1" name="form1" method="post" action=""
onsubmit="return confirm('This is irreversible. Are you sure?');">
<input type="hidden" name="act" value="run">
<input id="btnDelete" name="btnDelete" type="submit" value="Delete selected"/>
</form>
Upvotes: 3