Hey all.
I'm having a problem with dynamically changing an onclick event. I know there are two solutions to this:
myVar.onclick = some_function;
or
myVar.onclick = function(){some_function();};
so.. why does that not work ?? :
[HTML]<html>
<head><title></title>
<script language="text/javascript" type="text/javascript" src="test.js">
</script>
</head>
<body>
<a href="#" id="id">Click me!</a>
</body>
</html>[/HTML]
with test.js:
Code:
window.onLoad = initAll();
// on load
function initAll() {
var the_change = document.getElementById('id');
the_change.onclick=show_table;
}
function show_table() {
// whatever
}
note that the_change.onclick=function(){show_table();}; does not work neither ...
I'm lost .. honnestly.
thanks
plk