Forums

How to add a confirm popup to a submit button?

HerKle 19 Nov, 2016
Hi,

I searched now for a while through forum and faq, but still cannot find an answer:

I need to have a confirmation popup when hitting a submit button, before updating/deleting database records, eg. "Do you really want to do this?" With "Ok" and "Abort" as options.

In the Basic Submit Button I can't see anything providing this.

Thanks for your help!
Herbert
GreyHead 19 Nov, 2016
Hi HerKle,

I've never tried to do this. I think I would replace the submit button with an ordinary button and use JavaScript to add the confirmation message. If the response is yes then the script can submit the form.

Or, possibly better . . . add an extra page to the form where you show the data to be deleted and ask for confirmation there.

Bob
HerKle 19 Nov, 2016
Thanks Bob,

this is already the submit button on a confirmation page – and I want people to be really aware of that they are NOW deleting/changing things.

So on http://www.landofcode.com/javascript-tutorials/javascript-pop-up-boxes.php I found some code
<html>
<head>
<script type="text/javascript">

function confSubmit(form) {
if (confirm("Are you sure you want to submit the form?")) {
form.submit();
}

else {
alert("You decided to not submit the form!");
}
}
</script>
</head>
<body>

<form action="somefile.php" method="POST">
<!--Put form elements here-->

<input type="button" onClick="confSubmit(this.form);" value="Submit Form">
</form>

</body>
</html>


Now I wonder where are the places in ChronoForms to use something like this code…

Thx again!
Max_admin 22 Nov, 2016
Hi HerKle,

Please check the answers here:
http://stackoverflow.com/questions/6457750/form-confirm-before-submit

You can use that code in a "Load js" action, and you need to use the button id.

Check this tutorial:
How to add a confirm popup to a submit button? - ChronoForms8 - FAQs
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.