Solved

Confirm Delete of link with PHP and Javascript

Posted on 2011-09-15
3
303 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

863 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

23 Experts available now in Live!

Get 1:1 Help Now