programguru Posted February 4, 2009 Share Posted February 4, 2009 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!! Quote Link to comment Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 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? Quote Link to comment Share on other sites More sharing options...
programguru Posted February 4, 2009 Author Share Posted February 4, 2009 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"> Quote Link to comment Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 Look at this site Javascript Confirm(). They use href's is their examples, this should solve your problem. Quote Link to comment Share on other sites More sharing options...
programguru Posted February 4, 2009 Author Share Posted February 4, 2009 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"> Quote Link to comment Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 Good to hear you still may want to look at the confirm() link i posted it has some cool little features. Please click the SOLVED button. Quote Link to comment Share on other sites More sharing options...
programguru Posted February 4, 2009 Author Share Posted February 4, 2009 I will certainly check out that link you sent.. Thanks for your help! Good to hear you still may want to look at the confirm() link i posted it has some cool little features. Please click the SOLVED button. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.