Solved

Confirm Delete of link with PHP and Javascript

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

749 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