basic password check - quick help!! - javascript

goldy300

New Member
Messages
33
Reaction score
0
Points
0
Can someone help me with this... I don't know it yet but need to know it quick as I have a test on it tomorrow. Could you please make sure it's as basic as the instructions require.

Here's the question

Create a web application that will check your password. You are allowed three attempts. Use the body load event (<body onload = “functionName()”) to activate the function, and the prompt dialog box to obtain the password. If the password is successful, direct the User to a “good” page, otherwise direct the User to a “bad” page.
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Without actually knowing what your test is on and what you've already learned/supposed to have learned, I don't know exactly how to do that.
Where is the password coming from? I'll assume a basic level of JS tutoring, and the following is a function that may work (although the password could be revealed by viewing the source).
And I'm not sure how you would've been told how to 'direct to a page', so I've put a little comment where you need to add that bit.
Code:
<script type='text/javascript'>
function get_password() {
var count = 0;
var pass = 'Teh Paszw0rd!';
var guessed = 0;

while ((count < 3) && (guessed == 0)) {
  var input = window.prompt('What is the password?','');
  if (input == pass)
    guessed = 1;
  count++;
  }
if (guessed == 1) {
  // direct to 'good' page
  }
 else {
  // direct to 'bad' page
  }
}
</script>
 
Last edited:

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Um... 'directed revision' ;)

It's simple enough not to hinder someone's learning of the language (presuming they at least try), whilst also helping them to understand the basics.
 

mattura

Member
Messages
570
Reaction score
2
Points
18
I'd always feel happier helping those who say "I tried this and can't get it to work [posts code]" rather than those who say "This is my homework question - I don't know how to do it - can someone do it for me?"
 

compwhizii

Banned
Messages
779
Reaction score
0
Points
0
I'd always feel happier helping those who say "I tried this and can't get it to work [posts code]" rather than those who say "This is my homework question - I don't know how to do it - can someone do it for me?"

Thank you for sharing. I've saved it in /dev/null
 

goldy30

New Member
Messages
60
Reaction score
0
Points
0
I'd done approx 25 exercises in javascript to do with calculations and selections and I'd searched for similar things to do with iteration similar to the way the questions were put but I couldn't find any. Most of which were getting too complicated for me strait away. I just needed someone to show me how. Besides that, over the past two weeks, we've been swamped with tests on privacy, accessibility, php, databases, SQL and javascript. On top of that we've been trying to code our dynamic websites, prepare for the presentation next week and document status reports, meeting agenda's and attend weekly meetings.

It wasn't cheating, they weren't even the questions we were given on the test. But the questions to do with loops I had, I understood because of the guys who helped me here.

So a big fat thankyou to the guys who actually helped!!
 

mattura

Member
Messages
570
Reaction score
2
Points
18
lol

nah you just need to prioritise and manage your time better :p

then you can find many very helpful javascript tutorials which tell you all you need to know. There's nothing complicated in your task, even for those completely new to javascript.

Well you have your answer, so be happy! No need to justify yourself here, go learn javascript instead. It'll be a better way to spend your time...;)
 

unlikely

New Member
Messages
25
Reaction score
0
Points
0
I've never asked anyone to -do- a script for me. :B And never once did I take a class. Although I did once buy a php book *shame*...

But I used internet tutorials to teach me everything, from graphic and pixelated design, to html, to css.. to templates and layouts... And now I rock =D

Thank you... ! .. ppl who give tutorials! >>!
 
Top