Web Analytics Made Easy -
StatCounter Confirmation Help Please - CodingForum

Announcement

Collapse
No announcement yet.

Confirmation Help Please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Confirmation Help Please

    Okay, I am going to try and make this as simple, and understandable as possible...

    I have a page that when you open it, a confirmation appears(voila!). What I would like to know how to do is, how do you allow the person to continue to the page when he clicks OK. When he clicks Cancel, how do you send him to an alert that says Have a nice day!, then send him to the last page he was at..

    here is what I have for the code (not much, so that's why I asked you people.. )

    <script language="JavaScript">
    var enter=window.confirm("Enter? \n\n Click okay to enter. \n Click cancel to return to the previous page. \n\n Either way, you were given a choice.");
    // alert(" Welcome to ... "); is for the OK
    // alert(" Have a nice day! "); is for the CANCEL

    // I have no idea what goes in here for the OK alert to
    // redirection, and CANCEL alert to previous page
    // I don't know if I should use onClicks, or some other form of JS
    // I hope that somebody does...

    </script>
    Younger is better, I think. Sometimes.

  • #2
    <script>
    con = window.confirm("Do you agree?");
    if (con==false) {
    alert(" Have a nice day! ");
    opener.history.go(-1)
    }
    </script>

    Comment


    • #3
      When the user clicks ok, the confirm function returns the boolean true.

      When the user clicks cance, it returns the boolean false;

      So you can do something like this:


      var enter = comfirm("blah, click something");
      if (enter)
      {
      alert("you clicked ok");
      // other code you want executed
      }
      else
      {
      alert("you clicked cancel");
      // other code you want executed
      }
      Free Games For Your Website

      Comment


      • #4
        Thanks!

        that code works fine.. although I did have to change a few things around..

        comfirm.. to confirm but nothing majorly drastic


        Thanks!
        Richard
        Younger is better, I think. Sometimes.

        Comment

        Working...
        X