wagga2650 Posted August 24, 2009 Share Posted August 24, 2009 Hi. I have a conformation script that works well and when it pops up you have the option of ok or cancel. If you click on ok it will submit a form and I want it to return to a different page on my site if the user clicks cancel This is part of my code, It is only the head part I have the issue with the rest of the body is not important it is what the box pops up and the user clicks I can't get working In the head I have this <script type="text/javascript"> <!-- function confirmation() { var answer = confirm("Click ok to accept terms and submit form\r\nOtherwise click Cancel to return back to website") if (answer){ window.location = "terms2.htm"; } else{ window.location = "index.htm"; } } //--> </script> and in the body I have this <input type="button" onclick="confirmation()" value="submit"> thanks in advance for any help Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 24, 2009 Share Posted August 24, 2009 I'm not understanding what you want. What exactly isn't working. You start off by saying the script works well and then go into some other details that I'm not making sense of. For example, you state that when the user clicks "OK" that the form is submitted. THat would not be possible with the code you have posted - unless there is a JavaScript error somewhere on the page. The code you posted would redirect the page to another page and not submit the form. You script should be called onsubmit() of the form and would look something like this: Form Tag <form name="formName" onsubmit="return confirmation();" method="POST" action="somepage.php"> function confirmation() { var answer = confirm("Click ok to accept terms and submit form\r\nOtherwise click Cancel to return back to website") if (answer){ return true; } else{ window.location = "index.htm"; return false; } } 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.