- 1
Help, Please!
I made this code, and its not working. can someone give me a working copy? Thank You. This is my code: <script> function user() { var _user = {}; _user['p1'] = 'wyuw'; _user['p2'] = 'ethan'; var x = prompt("Enter Username"); if(x === _user['p1']){ pass(); } else if(x === _user['p2']){ pass(); } else{ alert("Error: No Such User Exists"); } } function pass(){ var _pass = {}; _pass['p1'] = '123'; _pass['p2'] = '321'; var x = prompt("Enter Password"); if(x === _pass['p1']){ alert("Welcome back, WYUW"); NewPage(); } else if(x === _pass['p2']){ alert("Welcome back, Ethan"); function NewPage(); } } </script> <body> <button onclick="user()">Login</button> </body>
3 Réponses
+ 4
function user() {
var _user = {};
_user['p1'] = 'wyuw';
_user['p2'] = 'ethan';
var x = prompt("Enter Username");
if(x === _user['p1']){
pass();
}
else if(x === _user['p2']){
pass();
}
else{
alert("Error: No Such User Exists");
}
}
function pass(){
var _pass = {};
_pass['p1'] = '123';
_pass['p2'] = '321';
var x = prompt("Enter Password");
if(x === _pass['p1']){
alert("Welcome back, WYUW");
NewPage();
}
else if(x === _pass['p2']){
alert("Welcome back, Ethan");
NewPage();
}
}
/*
your last call of NewPage() function is wrong (need to retrieve the 'function' keyword...
and anyway, you must define your NewPage() function elsewhere as this:
*/
function NewPage() {
/* code */
}
+ 3
It works very well if you just replace your <script> content with the fixed one I've previously posted:
https://code.sololearn.com/W7P5ajWImM2f/
- 1
I know, but NONE of the code is working.