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
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Multiple button functions

    Is there a way of adding more than one function to a button - such as displaying an answer and redirecting to a new page?

    Or am I just being too optimistic

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,077
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Try...
    Code:
    HTML:
    <button onclick="displayAnswerAndRedirect()">
    
    JS:
    function displayAnswerAndRedirect() {
    // code to show answer, probably with an alert() because redirection next will not display long.
    //...
    // code to redirect
      document.location.href = "http://somewhere.com?????";
    }
    Code is untested.,,

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <input type="button" name="" value="TEST" onmouseup="MyFunction1();MyFunction2();" />
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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