Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    two onClicks at once?

    Hello!

    I'm trying to run two onClick(s) at one time,, but only the first one is being hit,

    my code
    PHP Code:
        <input type="button" value="Delete" onClick="return confirm('Are you sure you want to delete this file?');" onClick="location.href='?action=del&id=<%=request("id")%>'" class="buttons" /> 
    how can I make both work?
    so that on the confirm if you OK, it will continue with the url?

    thanks in advance for your time!
    -SiX

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,529
    Thanks
    3
    Thanked 511 Times in 498 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    </head>
    
    <body>
    <input type="button" value="Delete" onClick="zxc=confirm('Are you sure you want to delete this file?'); if (zxc){window.top.location.href='http://www.vicsjavascripts.org.uk'; }" class="buttons" />
    </body>
    
    </html>

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You cannot have two (seperate) onClick calls (actually any type of method call) within the same tag. To run two function calls onClick just seperate the funciton calls with a semicolon, but inside the same onClick:
    Code:
    onClick="return confirm('Are you sure you want to delete this file?');" onClick="location.href='?action=del&id=<%=request("id")%>'"
    should be:

    Code:
    onClick="return confirm('Are you sure you want to delete this file?');location.href='?action=del&id=<%=request("id")%>'"

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    kool,
    that works

    thanks!

    -SiX


  •  

    Posting Permissions

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