Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Are you sure? Popup

  1. #1
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Are you sure? Popup

    Hello, i need something like this:



    When you click on a link, it starts a function, instead of start it inmediatelly, i need a pop up window like that one to show up asking the user if he really want to proceed, if he press accept, it starts the function and closes the window, if he press cancel, it does nothing and closes the window.

    Sorry about my bad english.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Code:
    function makesure() {
      if (confirm('Your message goes here. Continue?')) {
         dosomething();
        //or return true;
      }
      else {
        return false;
      }
    }
    Then call the function like so:

    Code:
    <a href="something.html" onclick="return makesure();">Some Text</a>
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Sorry about my bad english.
    It's quite good, actually.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    I can't seem to make it work, it doesn't show the pop up window, i will keep trying meanwhile.

    Thanks bouth of you for your replies.

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Do you have a link to your page, or even if you post the code you are trying to implement it in, we can take a look.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Sorry, here's the code (i just created a blank page to test),

    <?php

    function makesure() {
    if (confirm('Your message goes here. Continue?')) {
    return true;
    }
    else {
    return false;
    }
    }



    echo '<a href="#" onclick="return makesure();">PopUp</a>';

    ?>

    the link to my website is http://www.devilishmu.com/popup.php

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Oh, sorry; but I should have been clearer. The code I posted above is a javascript function, not php. The way you would have to do it is like so:

    Code:
    <html>
      <head>
        <title>Whatever</title>
    <script type="text/javascript">
     function makesure() {
      if (confirm('Your message goes here. Continue?')) {
        return true;
      }
      else {
        return false;
      }
     }
    </script>
      </head>
    <body>
     <a href="test.php" onclick="return makesure();">Go There</a>
    </body>
    </html>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by thetestingsite View Post
    Oh, sorry; but I should have been clearer. The code I posted above is a javascript function, not php. The way you would have to do it is like so:

    Code:
    <html>
      <head>
        <title>Whatever</title>
    <script type="text/javascript">
     function makesure() {
      if (confirm('Your message goes here. Continue?')) {
        return true;
      }
      else {
        return false;
      }
     }
    </script>
      </head>
    <body>
     <a href="test.php" onclick="return makesure();">Go There</a>
    </body>
    </html>
    Hope this helps.
    hehe, that would explain why when i searched on php.net for confirm() there wasn't any results

    I will try now, thanks again.


    EDIT: It works great, is there any way to change the title of the pop up? like WARNING or smth?

  9. #9
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    No, because it is part of the browser window and it is there for security purposes. The only way you could do something like that is by making a javascript function open a div that looks like that window. Other than that, sorry.

    Hope this helps nonetheless.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #10
    Join Date
    Jan 2007
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by thetestingsite View Post
    No, because it is part of the browser window and it is there for security purposes. The only way you could do something like that is by making a javascript function open a div that looks like that window. Other than that, sorry.

    Hope this helps nonetheless.
    Ok doesn't matter really, thanks you a lot.

    Now, another thing, i might need to open a new thread...

    Please check my registration form page (not agreement) http://www.devilishmu.com/?action=regme

    Would be useless to add an image verification to the form?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •