When I make a function which should be run after onclick event and the function is without argument it works fine - the function is launched after clicking the button. But when I want to pass some argument, the function is run right after loading the page without clicking the button. See both codes:
<script>
var hash_btn = document.getElementById("btn_hash");
var hash_txt = document.getElementById("txt_hash");
var test_f = function(txt)
{
alert('hello');
}
// this alerts 'hello' after clicking the button
hash_btn.onclick = test_f;
// this alerts 'hello' immediately without clicking the button
hash_btn.onclick = test_f('whatever');
</script>
<html>
<input type="text" id="txt_hash" />
<input type="button" id="btn_hash" value = "Hash"/>
</html>