473,503 Members | 9,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to do "comfirm delete dialog box" before confrim delete

88 New Member
hi

currently, i would like to do a "confirm delete dialog box" , before user really decide to delete. so when user click delete, dialog box will pop up , saying "confirm delete ?" if yes, then go to delete page, otherwise still remain in the same page. i don;t know how to do it, is there any simple method to solve this?

any one can help? thanks
Jul 14 '07 #1
7 26105
mwasif
802 Recognized Expert Contributor
Use confirm() function in the following context
Expand|Select|Wrap|Line Numbers
  1. onSubmit="return confirm('Do you want to delete?');"
Jul 14 '07 #2
kang jia
88 New Member
Use confirm() function in the following context
Expand|Select|Wrap|Line Numbers
  1. onSubmit="return confirm('Do you want to delete?');"
i am quite new to this. if "Yes" it should like to delete page else it will remain in the same page. there must be a place to link ba? hmm... can help me with this, thanks :)

PS, currently my application is like this: when user click "delete" link, it will just delete without any pop up box. it is very dangerous because user may accidently delete what they are not supposed to delete.
Jul 14 '07 #3
mwasif
802 Recognized Expert Contributor
Make your link <a> look like this
[HTML]<a href="http://some page link" onClick="return confirm('Do you want to delete?');">Delete</a>[/HTML]

If you click on OK, it will proceed to the delete page otherwise stays on the same page.
Jul 14 '07 #4
pbmods
5,821 Recognized Expert Expert
To do this without using javascript, you can use an intermediate page. Something like this:

delete.php has the form to select the record to delete. Submitting the form goes to...
confirm_delete.php will ask the User if he really wants to delete that record. Clicking delete will link to...
dbi/delete.php will actually delete the record. Then it redirects back to delete.php.
Jul 14 '07 #5
Atli
5,058 Recognized Expert Expert
To do this without using javascript, you can use an intermediate page. Something like this:

delete.php has the form to select the record to delete. Submitting the form goes to...
confirm_delete.php will ask the User if he really wants to delete that record. Clicking delete will link to...
dbi/delete.php will actually delete the record. Then it redirects back to delete.php.
I'd also reccomed somthing like this, its a little more 'user-friendly' than having a confirm box popping up, in my optinion.
Not to mention that this removes the need for extra Javascript, which is always a good thing.
Jul 15 '07 #6
kang jia
88 New Member
Make your link <a> look like this
[HTML]<a href="http://some page link" onClick="return confirm('Do you want to delete?');">Delete</a>[/HTML]

If you click on OK, it will proceed to the delete page otherwise stays on the same page.
it seems your suggestion does not work , my code is in the following:
Expand|Select|Wrap|Line Numbers
  1. $userid = $_SESSION['userid'];
  2. $sql1 = "SELECT * FROM orders WHERE id = '$userid'";
  3.  
  4. $results1 = mysql_query($sql1);
  5. if (mysql_num_rows($results1) == 0) {
  6.     echo "No items in your shopping cart yet<br>";
  7.     echo "<a href = 'index.php'>Go back to main page</a>";
  8. } else {
  9.     echo "<table border = 1><tr><th>Title</th><th>Brand</th><th>current price(1 piece)</th><th>quantity</th><th>size</th><th>delete?</th></tr>";
  10.     while ($row1 = mysql_fetch_array($results1)) {
  11.         $poster_id = $row1['imageid'];
  12.         $quantity=$row1['quantity'];
  13.         $size=$row1['size'];
  14.         $sql2 = "SELECT * FROM ladies WHERE id = '$poster_id'";
  15.         $results2 = mysql_query($sql2);
  16.         $row2 = mysql_fetch_array($results2);
  17.         $title = $row2['title'];
  18.         $brand = $row2['brand'];
  19.         $price = $row2['price'];
  20.         $cprice = $price * $cur->rateFromSGD($currency);
  21.         $rprice=round($cprice,2);
  22.         $tprice+=$rprice;
  23.         //echo "<tr><td>".$title."</td><td>".$artist."</td><td>".$cprice."</td></tr>";
  24.         echo "<tr><td>".$title."</td><td>".$brand."</td><td>".$rprice."</td><td>".$quantity."</td><td>".$size."</td><td><a href=\"do_delete3.php?id=".$poster_id."\" onClick='return confirm('Do you want to delete?');'>Delete</a></td></tr>";
  25.  
  26.     }
  27.  
in fact, there should two options, if click "yes" then go to delete.php, else remain, but after i try out this code, it seems it does not pop up anyting, it seems like they ignore this piece of code, can help me sovle this ASAP, because my project time is near to due. thanks
Jul 18 '07 #7
code green
1,726 Recognized Expert Top Contributor
it seems your suggestion does not work
That is because you have coded what you think it should be and not what Atli wrote
Expand|Select|Wrap|Line Numbers
  1. echo "<tr><td>".$title."</td><td>".$brand."</td><td>".$rprice."</td><td>".$quantity."</td><td>".$size."</td><td><a href=\"do_delete3.php?id=".$poster_id."\" onClick='return confirm('Do you want to delete?');'>Delete</a></td></tr>";
OK, for a start do away with the awful escapes on the quotes.
You have missed at least one. Write single quotes inside php and double quotes inside HTML. Then concatenate the two together [PHP]echo '<tr><td>'.$title.'</td><td>'.$brand.'</td><td>'.$rprice.'</td><td>'.$quantity.'</td><td>'.$size.'</td><td><a href="do_delete3.php?id='.$poster_id.' " onClick="return confirm('Do you want to delete?')";>Delete</a></td></tr>';[/PHP]Think i've done it right
Jul 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1246
by: Brian Takita | last post by:
Hello, Whenever I add an existing aspx/ascx file to the project, a dialog box saying "There is no class file in the project associaated with the Web Form 'blah.ascx'. Create a new class file...
4
5516
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. ...
1
2150
by: SrDhUS | last post by:
I get the following error when I try to add a web reference using Web Reference Dialog (VS .Net 2003) Error "The proxy settings on this computer are not configured correctly for web discovery."...
1
1679
by: Rob Doe | last post by:
Hello, I have a button on a form that brings up the dialog box you get when using Access's menu to do Insert/Object: RunCommand acCmdInsertObject I'd like to over-ride some default settings...
1
1502
by: Tomas Martinez | last post by:
Hi, In my web I have a proccess of download reports which on first step generates a PDF, then flushes the buffer (the generated file) and finally deletes this file from server. Ok, the problem...
2
10880
by: psanjay | last post by:
Hi, Am unable to open javascript SaveAs dialog box in Firefox browser. Following is the script, <a href="javascript:void(0);" onclick="document.execCommand('SaveAs',false,'*.xyz');">Save this...
3
8795
by: deciacco | last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview control to redraw the preview I get the...
1
6916
by: Sport Girl | last post by:
Hi everybody, please can anybody help with this question: I an working with Acees 2007, and everytime I run a report I have a dialog box prompting "Enter Parameter Value" requesting for a...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.