 |
 |
PHP/JavaScript Question.
|
 |
|
 |
|
Grizzled Veteran
Join Date: Aug 2002
Status:
Offline
|
|
Hello, I have the following line of code...
<td><? echo '<a href=delete.php?id='. $id .'>' . Delete . '</a>'; ?></td>
How can I add a JavaScript confirmation box to this line of code?
Thank!
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Well, since you are using a confirm dialogue, you'll want to actually use the users choice.
Here's a small page showing the basics, and degrades for those without javascript enabled/capable browsers.
Code:
<html>
<head>
<title>Confirm</title>
<script>
function goTo(url) {
if (confirm("Do you want to go to " + url + "?"))
document.location.href = url;
}
</script>
</head>
<body>
<a href="http://www.apple.com" onclick="goTo(this.href); return false">Go to Apple</a>
</body>
</html>
Hope that helps.
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Aug 2002
Status:
Offline
|
|
Originally posted by Black Book:
Well, since you are using a confirm dialogue, you'll want to actually use the users choice.
Here's a small page showing the basics, and degrades for those without javascript enabled/capable browsers.
Hope that helps.
Yeah, I tried some other code similar to what you have above but I can't get it to work with the PHP code that I posted.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
something.php:
[php]
<html>
<head>
<title>Confirm</title>
<script>
function goTo(url) {
if (confirm("Do you want to go to " + url + "?"))
document.location.href = url;
}
</script>
</head>
<body>
<table>
<tr>
<td>
<a href="delete.php?id='<?php echo $id ?>'" onclick="goTo(this.href); return false">Go to Apple</a>
</td>
<td> Something else</td>
</tr>
</table>
</body>
</html>
[/php]
What is actually happening at your end for it not to be working? What errors is it throwing?
(Last edited by Black Book; Apr 12, 2005 at 06:58 AM.
)
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Aug 2002
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |