SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist Brandon Luhring's Avatar
    Join Date
    Apr 2002
    Location
    IN, USA
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript confirm (with return true)

    Code:
    <a href="includes/delete.asp?Post=PostID" onClick="confirm('This will delete current post and all responses!');return true">X</a>
    That's the code I have so far. "PostID" is actually a dynamic variable placed by VBScript...

    When the user clicks on the link "X" the confirm box pops up with the appropriate message and [OK][Cancel] buttons.

    Problem is, if they hit [Cancel], it still runs the href URL deleting the posts anyway...

    I thought [Cancel] stopped the href action...

    Thanks in advance!
    Brandon

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    'Cancel' does return false, but you aren't listening for it with the event handler. Try this...
    Code:
    <a href="includes/delete.asp?Post=PostID" onClick="return confirm('This will delete current post and all responses!');">X</a>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Evangelist Brandon Luhring's Avatar
    Join Date
    Apr 2002
    Location
    IN, USA
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    works like a charm!

    thanks!


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
  •