Jump to content

[SOLVED] confirmation OK or CANCEL has the same result in ALL cases ?


programguru

Recommended Posts

i am unable to get this function i created to work properly. no matter what option i choose OK or CANCEL, the same result happens! I've tried many options to no avail? Anyone have any idea what the h%$# is wrong here?

 

function confirmation() {
var answer = confirm("Go somewhere else?")
if (answer){
	alert("Ok bye!")
	window.location = "REDIRECT-TO-ANOTHERPAGE.php";
}
else {
	alert("Thanks for sticking around!");
	window.location = "SHOULD-STAY-THE-SAME-PAGE.php";
}
}

 

Here is the link and function call:

 

<a onclick="confirmation()" href="review_edit_special.php">Edit</a>

 

SOS!!

Link to comment
Share on other sites

Is it not possible to do an href link? I don't like clunky buttons, and the code was partly given to me from my brother, so I am not sure where it is all from.

 

Looks like you were referring to tizag's tutorial on Confirm.  What's the point of calling the function on the href link?  Why don't you do a button?

 

<input type="button" onclick="confirmation()" value="Edit">

 

Link to comment
Share on other sites

I resolved the issue.

 

The script I was working with was overkill for my purposes.

 

I just created a function with one arg (address) and an if leading back to the address if canceled, and continuing to the new link if OK in the confirm.

 

Thanks for your help anyways..

 

SOLVED!!

 

 

 

 

 

Looks like you were referring to tizag's tutorial on Confirm.  What's the point of calling the function on the href link?  Why don't you do a button?

 

<input type="button" onclick="confirmation()" value="Edit">

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.