i have a funny problem here.
I have a textarea with an onchange event linked to it. Then i have a button linked to an onclick event.
The text being put to the textarea is processed when the onchange event gets triggered on the textarea. This normally happens when i click something outside of the textarea.
What i did was the following:
- I typed in a text into the textarea.
- Right after typing i click on the button to trigger the onclick event on the button
- Nothing happens, but the onchange event on the textarea got triggered when i clicked on the button, but the onclick event on the button itself doesnt get triggered.
Why? I expected to get both onchange and onclick triggered. Is there anything i need to do so the click on the button doesnt get "lost". I realized i have to click twice, because first click causes onchange on textarea, and THEN the second click triggers onclick on the button.
The code below shows an exmaple, just try the code below. Type in a text, then directly click on that button. Only the "textarea" popup will come up.
<textarea onchange="processText();" name="mytext"></textarea>
<button onclick="processButton();">Hello</button>
<script language="Javascript">
function processText()
{
alert( 'textarea');
}
function processButton()
{
alert( 'button');
}
</script>