Jump to content

Confirm box before saving data

- - - - -

  • Please log in to reply
1 reply to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 477 posts
Hi...

I have a button to generate data or save all data in the database.

Now, I want that when i click the button to generate data it will not save all data, i want first appear an alert or confirm box asking if "Do you want to save data?" and i want it has a OK and Cancel...when the OK was pressed it will automatically save data and when the Cancel was pressed the alert/confirm box will closed?


Is it possible?

Can you give me an idea or example..But now i searching also for that.


here is my code:

<input type="button" name="GENERATE_DATA" value="GENERATE DATA" style="width: 200px;">


and i have a php file for saving data...


Thank you so much

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
On yournform tag, use the onsubmit attribute to specify a javascript function to get the alert.
<form action="" method="post" onSubmit="return window.confirm('Do you want to save?');">
This means that if they answer yes, it will submit, otherwise, it just ignores the submission and stays put.
With this, your button isn't needed.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users