Lewis Smith February 2016

Can you execute two javascript functions with one submit button

I have two different option boxes in my form and then two different scripts to pull this data on the click is this how I execute both scripts or will this not work?

<input class="form-control" type="button" onclick="fun() && fun2()" value="Submit">

Answers


gurvinder372 February 2016

yes, make it

<input class="form-control" type="button" onclick="fun(); fun2();" value="Submit">

or you can call one function which will call both of them

<input class="form-control" type="button" onclick="fun();" value="Submit">

function fun()
{
  fun1();
  fun2();
}


deadpool_Y7 February 2016

Yes thats pretty easy:

function myFunction(){
  functionOne();
  functionTwo();
}

Then you can simply call myFunction on the onklick attribute

Post Status

Asked in February 2016
Viewed 3,667 times
Voted 13
Answered 2 times

Search




Leave an answer