...

View Full Version : Problem with confirm pop up window



spyros
04-30-2007, 12:52 PM
I have a link that I want when the user clicks on it a confirm pop-up to appear.
But itís not working.
Can you please help me?





echo '
</td><td width="15%" bgcolor="'.$bg_color.'" align="center" class="update"><div class="update">
<a href="index.php?autoid='. $autoid .'" class="update" OnClick= "return confirm("do you really want to delete")">DELETE</a></div></td></tr>';

spyros
04-30-2007, 02:20 PM
Thank you gesf

I tried this but itís still not working


<script language="javascript">
function cconfirmation(aid) {
var x = confirm("Do you really want to delete?");
if (x == true) {
window.location.replace(aid);
} else {
return false;
}
}
</script>

<td width="15%" bgcolor="<? echo $bg_color ?>" align="center" class="update"><div class="update">
<a href="javascript:cconfirmation(/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>)"
class="update">DELETE</a></div></td>

spyros
04-30-2007, 05:31 PM
Please Help

rwedge
04-30-2007, 05:49 PM
The argument in your 'cconfirmation' is a string and needs single quotes:
<td width="15%" bgcolor="<? echo $bg_color ?>" align="center" class="update"><div class="update">
<a href="javascript:cconfirmation('/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>')"
class="update">DELETE</a></div></td>

brandonH
04-30-2007, 05:51 PM
your second attempt is on the right track but you have an error in the syntax.

<a href="javascript:cconfirmation(/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>)"
class="update">DELETE</a>

should be:

<a href="javascript:cconfirmation('/index.php?deletestu=1&category=STUDENTS&quest=stu&autoid=<? echo $autoid ?>')"
class="update">DELETE</a>

spyros
04-30-2007, 06:59 PM
Thank you

glenngv
04-30-2007, 09:00 PM
Putting confirm in the onclick handler itself is better, you don't have to create a function and more importantly, the link will still work even if javascript is disabled.


echo '
</td><td width="15%" bgcolor="'.$bg_color.'" align="center" class="update"><div class="update">
<a href="index.php?autoid='. $autoid .'" class="update" OnClick= "return confirm(\'do you really want to delete\')">DELETE</a></div></td></tr>';
I escaped the single quote because the link is inside a PHP string delimited by single quotes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum