JavaScript Issue - Please Help

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
It's that time of the day again when your brain shuts down :)

Anyone know why this doesn't work? I really don't see why...

HTML:
<script type="text/javascript" src="scripts/sha1.js"></script>
<script type="text/javascript">
function $(id) {
	return document.getElementById(id);
}

function Submit() {
	if (!document.login.user.value) {document.login.user.style.backgroundColor="#FF7575"; return false;}
	if (!$("pass").value) {$("pass").style.backgroundColor="#FF7575"; return false;}
	document.login.pass.value = hex_sha1($("pass").value);
	document.login.submit();
	return true;
}
</script>
</head>
<body><br />
<h1 align="center">SQL Administration</h1><form action="#" method="post" name="login">
<input type="hidden" name="do" value="login" />
<input type="hidden" name="pass" value="" />
<table border="0" align="center">
<tr><td>Username:</td>
<td><input type="text" name="user" onfocus="this.style.backgroundColor='#FFFFCC';" onblur="this.style.backgroundColor='#FFFFFF';" /></form></td></tr>
<tr><td>Password:</td>
<td><input type="password" id="pass" onfocus="this.style.backgroundColor='#FFFFCC';" onblur="this.style.backgroundColor='#FFFFFF';" /></td></tr>
</table><br />
<center><input type="button" value=" Login " id="submit" /></center>
<script type="text/javascript">
$("submit").onclick = Submit;
document.login.onsubmit = Submit;
</script>
I get an error saying that document.login.submit() is not a function? Any help would be appreciated!
 
Last edited:

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
i'm not sure (because javascript is definatly not something i'm proficient at, not even close) but can that idea even work, seeing as the document.login.submit() is inside the head section. i've only ever seen that used in the body section.
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
Nope, I tried it but it didn't work. The function is not called until the body is loaded, or the user could not submit the form. Otherwise, the form would submit as soon as the page loads. Thanks for trying to help :)
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
why can't you just use a submit type input instead of a button type input?
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
I am using this diversion so I can hash the password before sending it using an encryption library. If I was using that same form for that instead of an inconspicuous hidden field, the user would wonder why his password enlarged 20 characters or so when submitting. Anyway, I found the error was that the id of the button was submit, which is apparently a bad thing. This the the type of generic error that makes you want to pull out your hair...

Thanks a lot for your help, I have you rep.
 
Last edited:
Top