I got a foreach loop which display many forms like this :
<form action="cree-new-user.php" method="post" class="formButtonForm">
<input type="hidden" name="ent" value="<?php echo $corp->id;?>" />
<input type="hidden" name="action" value="delete" />
<input type="submit" class="submit redform" value="delete" />
</form>
When i click on the Delete button it delete the objet in my database.
I would like to create a popup box to confirm if i “really” want to delete it.
I coded this with Javascript :
function Validate(event) {
var thereturn = confirm("Voulez vous vraiment effacer cette entreprise ?");
if (event) {
if (!thereturn) {
event.preventDefault();
}
} else {
return thereturn;
}
}
window.onload = function () {
document.getElementByName("deleteEntreprise").onclick = Validate;
}
It should display a alert popup, but nothing pop…
Do you guys have any clues ?
Even if you get the button correctly you should validate in the form on submit event.
if you return
falsein the function it won t submit the form.