- 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>

9th Jul 2017, 6:25 PM
❮вαιι–кιηgz❯ dario
❮вαιι–кιηgz❯ dario - avatar
3 Antworten
+ 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 */ }
9th Jul 2017, 6:37 PM
visph
visph - avatar
+ 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/
9th Jul 2017, 8:42 PM
visph
visph - avatar
- 1
I know, but NONE of the code is working.
9th Jul 2017, 8:20 PM
❮вαιι–кιηgz❯ dario
❮вαιι–кιηgz❯ dario - avatar