Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54

    Unanswered: Multiple calls with OnChange or OnClick

    Can you execute two functions one after another with onclick or onchange event?
    I'd like to 1) set the focus to a particular field; 2) execute a function with an onclick or onchange event.
    Can this be done? and how?

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Posts
    96
    Hi,
    you can create a function that calls other function, then you only have to call this function, that would be in javascript not in asp as you would have to reload the page to do so.

    In JS:

    Code:
     function funct1()
    {
    //have this function do what ever you want it to do
    
    }
    
    function funct2()
    {
    //same here with function 2
    
    }
    
    function callAboveFunctions()
    {
    funct1();
    funct2();
    
    }
    
    In your html <a href="javascript:callAboveFunctions();">Click here to trigger the 2 fonctions</a>
    Hope this helps

  3. #3
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54
    Thanks, this does help.

    But I guess I can't directly place two functions together in the onclick or onchange event.

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    I think what rweide was getting at is this....

    Code:
    <script>
    function func1() {
      //.....
    }
    
    function func2() {
      //.....
    }
    
    function doUpdate() {
      func1();
      func2();
    }
    </script>
    
    <input type="text" name="myTextbox" onClick="doUpdate();" onChange="doUpdate();">
    That which does not kill me postpones the inevitable.

  5. #5
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54
    Hmm, this helps.

    But what about <....onClick="doOneThing();" onClick="doAnotherThing();">??

    Can you do something like that? Two function calls in one OnClick event?

  6. #6
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    eh.. no.. you could do:

    <....onClick="doOneThing(); doAnotherThing();">

    or simply call a single function that calls doOneThing() and doAnotherThing()

    Code:
    <script>
    function doOneThing() {
      //.....
    }
    
    function doAnotherThing() {
      //.....
    }
    
    function doUpdate() {
      doOneThing();
      doAnotherThing();
    }
    </script>
    
    <input type="text" name="myTextbox" onClick="doUpdate();">
    That which does not kill me postpones the inevitable.

  7. #7
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54
    Thank you very much.

Posting Permissions

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