Current location: Hot Scripts Forums » Programming Languages » PHP » Yes / No from list of Delete buttons


Yes / No from list of Delete buttons

Reply
  #1 (permalink)  
Old 07-07-10, 05:14 PM
stringrv stringrv is offline
New Member
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Yes / No from list of Delete buttons

I have a list of buttons that can delete individual records from a database. This works!

A loop generates an array of buttons where the value is called to delete the record in the array according to a "for each" in a list. Works great! The delete button calls this function:

Quote:
if(isset($_POST['btnDelete'])) {
@$UpdateBTN= $_POST['btnDelete'];
while (list ($key, $val) = each ($UpdateBTN)){
$conVal = substr($val, 10);
$_SESSION['SaveNumber'] = $conVal;
mysql_query("DELETE FROM User_Selections WHERE SaveNumber = '" . $conVal . "'");
mysql_query("DELETE FROM User_Info WHERE SaveNumber = '" . $conVal . "'");
}
header("location: UserPage.php");
}
Now I want to be able to have a div window popup that will have yes and no as the choices. I have it working up to the point where the delete button in the loop makes the window visible and if you press no the window will become hidden. But I want to have the yes button perform the same action as the delete button in the loop used to do. The problem, how can the yes button know which record to delete when it is in a separate div window outside the loop? Currently the above code is dependent on an array of buttons.

Last edited by stringrv; 07-07-10 at 05:27 PM. Reason: Make Clearer
Reply With Quote
  #2 (permalink)  
Old 07-07-10, 05:45 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
The easiest way would be a confirm box.

Code:
<button type="submit" onclick="return confirm('Are you sure?');" value="21">Delete</button>
It isn't as pretty as a custom <div>, but is the easiest without a custom written javascript code.
Reply With Quote
  #3 (permalink)  
Old 07-07-10, 10:27 PM
stringrv stringrv is offline
New Member
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Works just great for me! Thanks!
Reply With Quote
Reply

Bookmarks

Tags
buttons in list, php


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image list and delete help JLS PHP 11 05-30-06 09:02 AM


All times are GMT -5. The time now is 08:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.