Page 1 of 1

Scenarios where event handler is not called

Posted: Thu Oct 05, 2006 7:57 pm
by LiveFree
Hello All,

Im looking for any reasons why this will not fire:

Code: Select all

....... html stuff....
<script type='text/javascript'>
     function checkuser() {
         alert("This is a test");
         var user = document.getElementById("user").value;
    }
</script>
........ more HTML .......
<input type='button' value='click me' name='hahaha' onclick='checkuser()' />
Of course my code has more detail than that, but the event handler is not firing and the alert() is not executing as well.



before anyone asks- I do have JavaScript enabled
:lol:

Posted: Thu Oct 05, 2006 8:01 pm
by Luke
do you have a javascript debugger?

Posted: Thu Oct 05, 2006 8:10 pm
by LiveFree
No,

Is there a relation between the location of the function def and the spelling of the event handler?

Re: Scenarios where event handler is not called

Posted: Thu Oct 05, 2006 8:20 pm
by s.dot
LiveFree wrote:Hello All,

Im looking for any reasons why this will not fire:
Erm.. it works for me... I copied and pasted your code into notepad, save as HTML file, ran it and it worked perfectly. It's likely your other html that is causing it to not fire.

Posted: Thu Oct 05, 2006 8:21 pm
by s.dot
LiveFree wrote:No,

Is there a relation between the location of the function def and the spelling of the event handler?
No, provided that the entire page has loaded. Spelling... yes. OnClick, onclick, and onClick will work.. but onlckick won't. :P