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>