Can anyone tell me why this doesn't write "Logged In"?
The program should run through and see that the user name, and password are correct, and display logged in. But it doesn't display anything...
The program should run through and see that the user name, and password are correct, and display logged in. But it doesn't display anything...
Code:
<script type = "text/javascript">
var users = new Array()
var pass = new Array()
users[0] = "Tyler"
users[1] = "Michelle"
users[2] = "Robert"
users[3] = "Cecily"
pass[0] = "TRL"
pass[1] = "MDL"
pass[2] = "RRL"
pass[3] = "CCL"
stat = checkInfo()
if (stat="yes")
{
document.write("Logged In")
}
else
{
document.write("Logged Out")
}
function checkInfo()
{
var x
var uname="Tyler"
var upass="TRL"
var pcheck
var stat
var ustat
var pstat
x=0
while (x<=3)
{
if (uname = users[x])
{
ustat = "yes"
pcheck = x
}
else {ustat="no"}
if (upass=pass[pcheck])
{
pstat="yes"
}
if (ustat="yes"&&pstat="yes") {stat="yes"}
else {stat="no"}
return stat
}
</script>