Web Analytics Made Easy -
StatCounter How come this doesn't work? - CodingForum

Announcement

Collapse
No announcement yet.

How come this doesn't work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How come this doesn't work?

    Code:
    <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>

  • #2
    <form name"frm"> is missing the = <form name="frm">

    ShriekForth

    Comment


    • #3
      Thanks for making feel really stupid.

      Have a good day!

      Comment


      • #4
        BTW...

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

        Thanks

        Comment


        • #5
          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

          Comment


          • #6
            Very Cool ShriekForth!

            I did not know that one.

            Comment

            Working...
            X