I found this script at javascript.internet.com and have it working (through the help of this forum) except it will not pull up the page that I need it to. I have substituted my usernames, and their passwords for member1 etc.., and the proper page in place of the generic page1, 2, 3 in the script. All I get is the file isn't found. All users will access the same page, not different pages. Can someone help? Thanks
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="member1" && password=="password1") { window.location="page1.html"; done=1; }
if (username=="member2" && password=="password2") { window.location="page2.html"; done=1; }
if (username=="member3" && password=="password3") { window.location="page3.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
I'm sorry, lets say this is the code below, all users have unique usernames and passwords, but will access the same members.html. I don't see why it won't work, it is basically as I downloaded it except the file they access is the same in all cases. It will work as far as returning the alert if the wrong password is entered.
if (username=="Elvis" && password=="houndog") { window.location="members.html"; done=1; }
if (username=="Norm" && password=="cheers") { window.location="members.html"; done=1; }
if (username=="Coach" && password=="dawber") { window.location="members.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
Perhaps, as gil suggested in another post, you could try using self.location.replace("xxxx.html")
If it is not finding the webpage you want, but the webpage exists, I guess just make sure you're targetting the exact location of the page.
I can't think of any reason why it wouldn't work.. unless Jscript hates successive if statements without any else, in which case you might want if... else if... else if.. and an else statement to support the else if statements...
if (blah blah == blah) { stuff; done=1; }
else if (blah blah == blah2) { stuff; done=1; }
else { done=0; }
I am not sayin that will work, but that is all i can think of... :/ sry
Bookmarks