Calling a function of a button from another button

html, javascript

Solution

<input type="button" onclick="fnc()"/>
<input type="button" id="message" onclick="alert('ok')" />
<script type="text/javascript">
function fnc()
{

document.getElementById("message").click();
}
</script>

are you looking for this?

Problem

I have a complicated case here, but below is an example just to make it simple. I have two buttons, each with their own onClick function. I want to call the onClick function of button A when I click on button B. ``` <input id="buttonA" type="button" value="BUTTON A" onMouseUp="sayHiA()"></input> <input id="buttonB" type="button" value="BUTTON B" onClick="sayHiB()"></input> ``` Note that the event can be onClick() or onMouseUp() p.s. I have to do it using only javascript. (NO jQuery). Thanks

Original source