Forum Moderators: coopster
I have a modify button on my page. The user can make changes on the page and click on "modify" to save changes in the database.
When the user clicks the button I want a message box to appear saying
" this will change data in the database. Do you want to go ahead?" with 'yes' 'no' options
Regards
Swati
Here is a JavaScript I think does what you want. (I didn't write this so if it doesn't work you should ask for a better one in the JavaScript forum.
YOUR LINK:
<a href="yourpage.htm" onClick="var flg=my_message(); return flg;"> Click Here</a>
PUT THIS IN YOUR HEAD TAG SOMEWHERE:
<script type="text/javascript">
function my_message() {
var flg=confirm('Your warning message here.\n\nClick OK to continue. Otherwise click Cancel.\n');
if (flg)return true;
return false;
} </script>
<script type="text/javascript">
function confirmModifications() {
if (window.confirm("This will change data in the database.
Do you want to go ahead?")) {
// Change the data...
} else {
// Don't change the data...
}
}
</script>
<edit>thanks kapow; looks like a two for one deal today :)</edit>
If you want something in PHP, you'll have to send an additional request back to the server to handle the confirmation.