Home Ask Login Register

Developers Planet

Your answer is one click away!

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">


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()

deadpool_Y7 February 2016

Yes thats pretty easy:

function myFunction(){

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


Leave an answer

Quote of the day: live life