Solved

Confirm Delete of link with PHP and Javascript

Posted on 2011-09-15
3
301 Views
Last Modified: 2012-05-12
How do I add a PHP Variable to the onclick confirm statement. Right now i can get it to only say are you sure you want to delete this? I would like to replace the "this" with a php variable $ID but its not working.
<a href='.$deletethis.$row[$colID].'" onclick="javascript:return confirm(\'Are you sure you want to delete this?\')">'.$deleteIMG.'</a>';

Open in new window


I want it to do this but its not working.
<a href='.$deletethis.$row[$colID].'" onclick="javascript:return confirm(\'Are you sure you want to delete $ID ?\')">'.$deleteIMG.'</a>';

Open in new window

0
Comment
Question by:phat_code
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36545965

echo '<a href="' . $deletethis.$row[$colID] . '" onclick="javascript:return confirm(\'Are you sure you want to delete " . $ID . '?\')">' . $deleteIMG . '</a>';

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36545972
correction :
echo '<a href="' . $deletethis.$row[$colID] . '" onclick="javascript:return confirm(\'Are you sure you want to delete ' . $ID . '?\')">' . $deleteIMG . '</a>'; 

Open in new window

0
 

Author Comment

by:phat_code
ID: 36546127
oops I was missing the quotes thank you!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now