Click to See Complete Forum and Search --> : Password script


madddidley
12-18-2003, 04:13 PM
I'm new to JavaScript and not really sure what to do. I kept on getting an error saying that var idOne is undefined. It would be awesome if some one could help me.


<HTML>


<HEAD>


<TITLE>Password</TITLE>



<!--PASSWORD FUNCTION-->
<script language="javascript">
<!--

function passWord() {

var userName = document.myForm.name.value;
var pssWrd = document.myForm.password.value;
var idOne = userone;
var idTwo = usertwo;
var idThree = userthree;

var psw1 = 1111;
var psw2 = 2222;
var psw3 = 3333;




//ASSUMING THERE IS A HANK.HTM
if (userName=="idOne" && pssWrd=="psw1") {
document.location.href="hank.htm";
}

if (userName=="idTwo" && pssWrd=="psw2") {
document.location.href="hank.htm";
}

if (userName=="idThree" && pssWrd=="psw3") {
document.location.href="hank.htm";
}

else { alert("Invalid Information") }




}

//-->
</script>


<style>
<!--

div.loginBox {
background-color: black;
color: white;
border-width: 5px;
border-color: white;
width: 200px;
height: 200px;
padding: 10px;
outline-width: 5px;
}

-->
</style>


</HEAD>


<BODY bgcolor="#7F8586">

<div class="loginBox">
<form name="myForm">
<div align="center">
User Name: <input type="text" size="10" name="name"> <br>

Password: <input type="password" size="10" name="password"> <br>

<br>
<input type="button" value="Login" onClick="passWord()">
</div>
</form>
</div>



</BODY>

</HTML>

danscan
12-18-2003, 04:25 PM
Your varibles are not set to strings you need quotes.

var IDONE = IDONE2;

Should be

var IDONE = "IDONE2";

it is reading them as varibles not as literal strings.