?
Solved

Confirm Delete of link with PHP and Javascript

Posted on 2011-09-15
3
Medium Priority
?
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

765 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