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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Help with simple onclick event

    I am trying to redirect a user a different page when a button is clicked but instead of redirecting like I want it submits the form. Can someone tell me the correct way to do this?

    here is my code

    Code:
    <button onclick="location.replace("http://google.com");">Cancel</button>

  • #2
    New Coder
    Join Date
    Dec 2007
    Posts
    14
    Thanks
    0
    Thanked 5 Times in 5 Posts
    onclick ="document.my_form.submit()"

    where my_form is the name of the form

    (But why don't you use a submit button???)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    <input type = "button" value = "Cancel" onclick="window.location = 'http://google.com'">


  •  

    Posting Permissions

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