Randy Thomas
Randy Thomas

Reputation: 343

javascript confirm box is not working as should

I have a confirm box for 2 different links. It works if I only use one or the other (meaning delete the other function) but when I have both functions, neither one works, it just goes right to the url of the link.

Here is the html

function myReset() {
  if (confirm("This will reset all counters for this campaign back to 0. \nAre you sure?") == true) {
    return true;
  } else {
    return false;
  }

}

function myDel() {
  if (confirm("This will completely delete this campaign. Any traffic to it will be lost.\nAre you sure?") == true) {
    return true;
  } else {
    return false;
  }

}
<a href="campaignmanager?todo=reset&id=$myrow[id]" alt="Reset This Campaign" title="Reset This Campaign" onclick="return myReset()">
  <img src="images/icon-reset.png" border="0">
</a>&nbsp;&nbsp;
<a href="campaignmanager?todo=delete&id=$myrow[id]" alt="Delete This Campaign" title="Delete This Campaign" onclick="return myDel()">
  <img src="images/icon-delete.png" border="0">
</a>

Any help would be great.

Upvotes: 0

Views: 42

Answers (1)

depperm
depperm

Reputation: 10746

--Edit-- Just place the confirmation inline.

<a href="campaignmanager?todo=reset&id=$myrow[id]" alt="Reset This Campaign" title="Reset This Campaign" onclick="return confirm('This will reset all counters for this campaign back to 0. \nAre you sure?')"><img src="images/icon-reset.png" border="0"></a>&nbsp;&nbsp;<a href="campaignmanager?todo=delete&id=$myrow[id]" alt="Delete This Campaign" title="Delete This Campaign" onclick="return confirm('This will completely delete this campaign. Any traffic to it will be lost.\nAre you sure?')"><img src="images/icon-delete.png" border="0"></a>

Upvotes: 2

Related Questions