View Single Post
Old 02-08-2012, 06:59 AM   PM User | #6
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,857
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
just remember that the HTML event attributes are not the same as the JavaScript event properties. the former require a parseable JavaScript expression/statement, while the latter require a function. there are also differences in the used scope and automatically passed parameters.

PHP Code:
function test()
{
    
alert(this); // show scope
    
alert(arguments[0]); // show 1st passed parameter

PHP Code:
<button type="button" id="a_button" onclick="test();">click me</button>
<
button type="button" id="another_button">click me</button>
<
script type="text/javascript">
document.getElementById("another_button").onclick test;
</script> 
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote