fallenangel1983 Posted March 30, 2008 Share Posted March 30, 2008 Hey all, I have a button on a page and its purpose is to delete a ecord form a table. Is there a way to have a essage box flash up saying... are you sure you wish to delete? and two options stating ok or cancel. if ok is pressed then delete the record . if cancel is pressed do not delete just return to previous pge. i have looked through the tutorials and an find nothing that relates to this. can you help. cheers. Link to comment https://forums.phpfreaks.com/topic/98629-message-box/ Share on other sites More sharing options...
tibberous Posted March 30, 2008 Share Posted March 30, 2008 <input type='submit' value='Delete' onclick="return confirm('REALLY?')"> Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504726 Share on other sites More sharing options...
fallenangel1983 Posted March 30, 2008 Author Share Posted March 30, 2008 Wow surprising didnt comprehend it could be that simple. i thought i may have to implement some java script. But thanks anyway ill give it a try Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504730 Share on other sites More sharing options...
fallenangel1983 Posted March 30, 2008 Author Share Posted March 30, 2008 Right that works great. so thank you. Next i have to then get the message button to run a query if ok is pressed. any ideas? Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504732 Share on other sites More sharing options...
lewis987 Posted March 30, 2008 Share Posted March 30, 2008 YOu will need to use either: AJAX or javascript... it is pretty easy to use ajax... ill post up some code if you want, but you will need to supply me with the original code you have... Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504735 Share on other sites More sharing options...
fallenangel1983 Posted March 30, 2008 Author Share Posted March 30, 2008 i appreciate the help but i think i will just implement some javascript to d this part as it much simpler. but thank you anyway for yourmtime. cheers Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504736 Share on other sites More sharing options...
lewis987 Posted March 30, 2008 Share Posted March 30, 2008 Well... if you want to implement AJAX then just give me a shout and ill help... Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504739 Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 Here a php aproach, not all users have javascript turn on be carefull......... Try it for fun..... <?php session_start(); $_SESSION['name']="redarrow"; if($_POST['submit']){ if($_GET['cmd']=="delete"){ echo" PLEASE BE ADVISED DELETING ALL DATA PLEASE CONFIRM! <p></p>"; $self=$_SERVER['PHP_SELF']; echo" <form method='POST' action='$self?cmd=yes'> <input type='text' value='".$_SESSION['name']."'> <input type='submit' name='submit' value='CONFIRM DELETE'> </form>"; exit; } if($_GET['cmd']=="yes"){ unset($_SESSION['name']); echo" USERNAME DELETED! ".$_SESSION['name']." "; exit; } } $self=$_SERVER['PHP_SELF']; echo" <form method='POST' action='$self?cmd=delete'> <input type='text' value='".$_SESSION['name']."'> <input type='submit' name='submit' value='DELETE DATA'> </form>"; ?> Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504745 Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 Remember javascript/ajax is client side not server side hence script lanauage not a programming lanuage........ Now let say 100 hits to my web site, let say only 1 out off 10 got javascript off, out off 100 people that 10 people but guess what them 10 people wanted to buy 10 exspensive items i lost money havent i ! DO NOT RELY ON JAVASCRIPT! Link to comment https://forums.phpfreaks.com/topic/98629-message-box/#findComment-504760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.