SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Alert message

  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Planet Earth
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Alert message

    Hi

    I have an alert message that ask you to confirm if you want to delete a record or not. The thing is that even when I click on cancel it still deletes the record.
    How can I set a behaviour that deletes the record if answer is yes and only closes the alert if it is no

    i have done this:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    <script type="text/JavaScript">

    function MM_popupMsg(msg) {
    confirm(msg);
    }

    </script>

    and the link comes from:

    <a href="delete.php?id=<?php echo $row['id']; ?>" onclick="MM_popupMsg('Are you sure you want to delete this record?')">Delete
    </a>
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Thank you a lot 4 any help provided
    "The Internet ? Is that thing still around ?"

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,420
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    confirm

    The confirm returns TRUE or not. So you could try something like
    HTML Code:
    if (confirm(msg)){
    /* do yes stuff*/
    } else {
    /* do no stuff */
    }

  3. #3
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Planet Earth
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mittineague!!

    Well, do you know a site where I can learn how to create the actions for 'do yes and no stuff'?

    As you can see here, I'm new at Javacscript

    thank you again
    "The Internet ? Is that thing still around ?"

  4. #4
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had this happen to me as well and had a friend take a look at it and he resolved the problem. I will ask him about this.
    The ConsumerTreehouse.com Team
    www.consumertreehouse.com

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    The best way to do a simple confirm, is to return the result straight from it.

    Code JavaScript:
    function MM_popupMsg(msg) {
      return confirm(msg);
    }

    If they click yes, the form will get submitted, the event will take place, if they click cancel, it won't.


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
  •