PDA

View Full Version : How come this doesn't work?


Hawk
07-12-2002, 07:01 PM
<html>
<head>
<script>
function f_PasswordCheck(str_redirect)
{
var str_password = "Password";
var str_answer = document.frm.txt_Password.value;
if (str_answer==str_password)
{
//PURPOSE: Correct Answer
self.location.href=str_redirect;
}
}
</script>
</head>

<body>
<form name"frm">
<input type="password" name="txt_Password" value="">
<br>
<input type="button" name="cmd_Submit" value="Password Check" onClick="f_PasswordCheck('http://www.yahoo.com');">
</form>
</body>
</html>

ShriekForth
07-12-2002, 07:08 PM
<form name"frm"> is missing the = <form name="frm">

ShriekForth

Hawk
07-12-2002, 09:06 PM
Thanks for making feel really stupid. :D:D:D:D

Have a good day!

Hawk
07-12-2002, 09:09 PM
BTW...

How would you use a submit button in this example instead of a button?

Thanks

ShriekForth
07-13-2002, 01:56 AM
You could leave the action blank, and use the OnSubmit function of the form. That would capture the Enter if it was IE anyway.

<form name="frm" onSubmit="f_PasswordCheck('http://www.yahoo.com')">

<input type="submit" name="submit" value="Password Check">
</form>

Then have PasswordCheck return false; and it will not actually submit the form.

ShriekForth

Hawk
07-13-2002, 07:27 PM
Very Cool ShriekForth!

I did not know that one.