Jump to content

Conformation script issue


wagga2650

Recommended Posts

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

 

Link to comment
Share on other sites

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;
    }
}

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.