jbingman Posted October 2, 2007 Share Posted October 2, 2007 I have a php/mysql script that i have update information in a mysql database and when the user clicks "save" they should get a confirm box asking if they want to continue. How can i integrate this javascript into PHP? Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/ Share on other sites More sharing options...
RichardRotterdam Posted October 2, 2007 Share Posted October 2, 2007 Ok so if I am right you want this (not working example) you have a button which calls a function <button onClick="save">a button</button> this calls a function <script> function save(){ var confirmSaveBox=confirm("do you wish to save"); if(confirmSaveBox==true){ //alert('save'); //call php page to update mysql } } </script> now do you want this to happen without refreshing the page? or do you wish to redirect to a page submitting the values with a form Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/#findComment-359763 Share on other sites More sharing options...
jbingman Posted October 2, 2007 Author Share Posted October 2, 2007 Yes thats exactly what i want. Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/#findComment-359766 Share on other sites More sharing options...
RichardRotterdam Posted October 2, 2007 Share Posted October 2, 2007 with or without refreshing the page? if you want this to happen without a refresh you'll need an ajax funtion Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/#findComment-359769 Share on other sites More sharing options...
jbingman Posted October 2, 2007 Author Share Posted October 2, 2007 um without refreshing the page. so once they fill in the values in the form, it will submit then to the mysql database if they click "ok" and keep them on the same page if they click "cancel". Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/#findComment-359778 Share on other sites More sharing options...
nikkieijpen Posted October 2, 2007 Share Posted October 2, 2007 Javascript (put it in the 'head' tag): <script language="javascript" type="text/javascript"> function saveForm(){ var confirmSaveBox = confirm("Do you wish to save?"); if(confirmSaveBox == true){ document.form1.submit(); } } </script> HMTL: <form name="form1" action="save.php"> <input type="button" value="Save!" onClick="saveForm();" /> </form> Link to comment https://forums.phpfreaks.com/topic/71462-solved-javascript-confirm-box-in-php/#findComment-359950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.