newphpcoder Posted December 19, 2011 Share Posted December 19, 2011 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 Link to comment Share on other sites More sharing options...
niche Posted December 19, 2011 Share Posted December 19, 2011 How do you plan to get your data to your php script assuming you're going that route? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2011 Share Posted December 19, 2011 Javascript has a window.confirm function you can use to show a confirmation box. Link to comment Share on other sites More sharing options...
DarkxPunk Posted December 20, 2011 Share Posted December 20, 2011 I would think you need the button to submit the data to not actually submit but rather open a function with your dialog box and that dialog box will have the ok button attached to the function that will save the data. Like this (do not copy and paste this is simply rough) function confirm(){var r=confirm("Is your data correct?")if (r==true) { saveData() }}function saveData()}//Whatever you need to distinguish the input fields and to save the data.{ Hope that is clear. Link to comment Share on other sites More sharing options...
Ingolme Posted December 21, 2011 Share Posted December 21, 2011 You're overwriting the original confirm() function by calling your function confirm(). Give it a different name. Link to comment Share on other sites More sharing options...
regicidedelferoz Posted January 3, 2012 Share Posted January 3, 2012 <input type="button" name="GENERATE_DATA" value="GENERATE DATA" style="width: 200px;" onclick="return confirm('Do you want to save data?')"> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.