[Solved] Need help replicating a little bit of JavaScript


I’m not sure I entirely understand the question, I think you could just do this:

<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Enter Store Code Here',' ');
while (testV < 3) {
if (!pass1) 
history.go(-1);
if (pass1.toUpperCase() == "CUSTOMPASSWORD1234") {
alert('You are being redirected!');
window.open('CUSTOMPASSWORD1234.html');
break;
} 
else if (pass1.toUpperCase() == "CUSTOMPASSWORD2"){
window.open('CUSTOMPASSWORD2.html');
break;
}

testV+=1;
var pass1 = 
prompt('Access Denied - Store Code Not Recognised, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3) 
history.go(-1);
return " ";
} 
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Enter Store Code" onClick="passWord()">
</FORM>
</CENTER>

You also have what I assume is an error with

(pass1.toLowerCase() == "CUSTOMPASSWORD1234")

since this will never evaluate to true since CUSTOMPASSWORD1234 is upper case. Also you don’t have an evaluation for CUSTOMPASSWORD1.

It seems like you’re lacking in basic JS and programming knowledge so I’d recommend reading some basic tutorial in programming concepts before you start building stuff. Just hacking together tutorials will make spaghetti code and you won’t learn.

Trent’s answer is better design which you should use, this answer is just how to specifically implement what you are asking for.

2

solved Need help replicating a little bit of JavaScript