PDA

View Full Version : confirm alert


nikko50
05-15-2004, 12:04 AM
Hello there. I have a link that when clicked will ask to confirm to continue to the next page or cancel to stay put. If I select either option they both go to the next page. What am I doing wrong??

<a href= deleteshiplist.php?rowid=$line[id]; onClick=confirm('Click OK to continue.')><font color='#0000FF'> Delete</font> </a>

Basscyst
05-15-2004, 12:35 AM
Try this:

<html>
<head>
<script type="text/javascript">
function newPage(url)
{
var sure=confirm('Click OK To Continue');
if(sure==true)
{
window.location.href=url;
}
}
</script>
</head>
<body>
<a href="#" onclick="newPage('http://www.codingforums.com')">Click</a>
</body>


Basscyst

nikko50
05-15-2004, 01:28 AM
Heelo there. I got a link here with a couple onclick functions. I know the confirm function works because it works on a previous form. On this link the confirm box pops up but when I click ok or cancel nothing happens. I think it may have to do with the second popup function.Any ideas???

<td width=6%><font color=#0033CC size=3><a href=\"#\" onclick=\"return confirm_entry() ; window.open('deletensirow.php?rowid=" . $row['id'] ."', '',
'width=500,height=400,scrollbars=yes, status=no'); return false;\" ><font color='#0000FF'>Delete</font> </a></td>

Basscyst
05-15-2004, 01:46 AM
Hello,

Sorry I didn't fully answer your question in the last post. I ran short on time. In your first bit of code you have the href defined in html, so it will follow the path regardless of the result of the confirm, I could be wrong but I'm pretty sure you need to check the value of confirm by declaring it as a variable. In the above code the variable sure, will equal false on cancel and true on ok.

Not real sure on the second post as we would have to see the code for the functions being called. Allthough correct syntax should be


<a href="deleteshiplist.php?rowid=$line[id]" onClick="confirm('Click OK to continue.')"><font color="#0000FF">Delete</font></a>


Basscyst