How to call two methods on button's onclick method in HTML or JavaScript?

The Solution to How to call two methods on button's onclick method in HTML or JavaScript? is


  1. Try this:

    <input type="button" onclick="function1();function2();" value="Call2Functions" />
    
  2. Or, call second function at the end of first function:

       function func1(){
         //--- some logic
         func2();
       }
    
       function func2(){
        //--- some logic
       }
    

    ...and call func1() onclick of button:

    <input type="button" onclick="func1();" value="Call2Functions" />
    

~ Answered on 2011-05-04 10:57:40


Most Viewed Questions: