Forum Moderators: open

Message Too Old, No Replies

Calling button click even from javascript function

         

faisalgeek

7:52 am on Sep 22, 2008 (gmt 0)

10+ Year Member



function explicitClick(){
//here i want to explicitly call the click event of btnLoad button when i use explicitClick() else where in the document.
}

<input type="button" id="btnLoad" onclick="somefunction()">

Please, anyone have a solution?

astupidname

6:02 pm on Sep 27, 2008 (gmt 0)

10+ Year Member



function explicitClick(){
//here i want to explicitly call the click event of btnLoad button when i use explicitClick() else where in the document.
}
<input type="button" id="btnLoad" onclick="somefunction()">

Your post is a bit unclear. But if I think I understand what you are asking, you want to also run the somefunction() when explicitClick() is called on from a different onclick event in another element?
Then simply do this:

function somefunction(){
alert("This is somefunction()");
}

function explicitClick(){
somefunction();
alert("This is explicitClick()");
}

<input type="button" id="btnLoad" onclick="somefunction()">

<input type="button" id="OtherbtnLoad" onclick="explicitClick()">

Alternatively, and perhaps less cleanly in the html code, you could just call two functions in the onclick:

<input type="button" id="OtherbtnLoad" onclick="somefunction(); explicitClick();">