This code is from a PHP software (using Smarty template engine) and it works:
<input type=\"button\" class=\"btn btn-primary\" value=\"{$LANG["phrase_send_email"]}\" onclick=\"ms.edit_submission_page_send_email($submission_id); this.disabled=true;\" />";
A user clicks on the button and the software will:
I want it to do more: adding a popup confirmation dialog box. The purpose is to remind the human to do something first by reading the text message in the confirmation dialog box before sending an email.
So if the user clicks OK:
or if the user cancels:
There are plenty of JavaScript if else/confirm examples. But I'm new to JavaScript and have no idea how ms.edit_submission_page_send_email($submission_id) fits into the JavaScript world.
How would one put all of this into a JavaScript function?
Try this way.
<input type=\"button\" class=\"btn btn-primary\" value=\"{$LANG["phrase_send_email"]}\" onclick=\"{literal}return checkValidMailSend(this, $submission_id){/literal}\" />";
{literal}
<script>
function checkValidMailSend(this, submissionid) {
if(!confirm("Are you sure to send mail?")) {
return false;
}
else {
ms.edit_submission_page_send_email(submissionid);
this.disabled=true;
}
}
</script>
{/literal}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.