Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two functions in JavaScript onclick event?

<a href="#" type="image"  class="topopup"  onclick="ShowDIV3();"  >Click Here</a>

In this code I need to execute another one function like validation if that function is true only the next function should run otherwise it won't be run. Can any one help me?

like image 803
user2586738 Avatar asked Jan 19 '26 11:01

user2586738


2 Answers

Try this code :

<a href="#" type="image"  class="topopup"  onclick="if (ShowDIV3()) {myotherfunction()}">Click Here</a>
like image 121
Lucas Willems Avatar answered Jan 22 '26 02:01

Lucas Willems


Try like

<a href="#" type="image"  class="topopup"  onclick="ShowDIV3();"  >Click Here</a>

function ShowDIV3() {
    if(true)   //Here can use condition for validation
       another_fun();
    else
       return false;
}

call your another function when the condition is true at your showDIV3 function

like image 40
Gautam3164 Avatar answered Jan 22 '26 02:01

Gautam3164