I am new to web dev and for a school exercise, I'm working on something where I want to execute javascript of form submit event.
<head>
<script>
function foobar() {
alert('Form submit event hit!');
}
</script>
</head>
<body onload="document.myForm.submit()">
<form name="login" id="login" action="login.php" method="POST" onsubmit="foobar();">
<input type="hidden" name="username" .../>
<input type="hidden" name="password" .../>
<input type="submit" name="submit" value="submit" />
</form>
</body>
When i execute this, I see that form gets submitted successfully that I see the output after successful login. But, I don't see the submit event's handler Java script getting called or hit. I'm sure I'm missing something. Any help is appreciated.