Closed Thread Icon

Topic awaiting preservation: Password exersice 2. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8705" title="Pages that link to Topic awaiting preservation: Password exersice 2. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Password exersice 2. <span class="small">(Page 1 of 1)</span>\

 
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-09-2003 04:26

Hi, guys. How are you? I am just back from lunch.
This problem has been with me for a copuple of weeks.
I'd love to solve this! But I am afraid I am totally stuck.
would you have time to read this?

My mission:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre><html>
<head>
<script type="text/javascript">
function guessIt()
{
var pass="Hiroki";
var ans = 0;
var i = 0;
while (ans != pass

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-09-2003 04:54

Hmm....I made a bit progress. I am trying to code simillar exercise.
In this exercise, user input word in the text box. Then prompt box ask user to reenter the word. If the twos are same, print "thanks for log in" otherwise user can try up to 4 times then if fails, alert says none of your business.
Please see my code below:

code:
<html>
<head>
<script type="text/javascript">
function logIn(){

var Pass=document.theForm.pass.value;
var ans=0;
var i=0;

while(i<=3){

if(Pass!=ans){
ans=prompt("Re-enter the password again");
}else{
document.write("thanks for your log in!");
}
i++;
}
if(ans != Pass){
alert("None of your business");
}
}
</script>
</head>

<body>

<form name="theForm">
<p>
Enter your password:
<input type="password" name="pass">
<p />

<p>
<input type="button" value="Submit" onClick="logIn()">
<input type="reset" value="Reset">
</p>
</form>

</body>

</html>



Here is uploaded file2.

There is two problem.
1.In the prompt box, if user clicks "calcel", ,message "thanks for log in" is printed.
2.When input everything colletly, "thanks for log in" is printed coule of times. I wanted jsut once.

Hhmm.....Would you know how to control cancel button of prompt box? And how to stop printing same statement???



Hiroki Kozai

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 06-09-2003 19:02

Im not sure exactly what you are looking for, but try this altered version of your code:

<html>
<head>
<script type="text/javascript">
function logIn(){

var Pass=document.theForm.pass.value;
var ans=0;
var i=0;

if(Pass==""){

alert("Enter the password");
}
else {
while(Pass!=ans){

ans=prompt("Enter the password","");

}
if (Pass==ans) document.write("thanks for your login!")
}
}
</script>
</head>

<body>

<form name="theForm">
<p>
Enter your password:
<input type="password" name="pass">
<p />

<p>
<input type="button" value="Submit" onClick="logIn()">
<input type="reset" value="Reset">
</p>
</form>

</body>

</html>

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 06-10-2003 06:59

Hi, mate.
Many thanks for your reply.
I am trying to figure out how you code.
I ran your code. Works great.
Now it is time to reverse it myself.
many many thanks for your help.
Cya.

Hiroki Kozai

« BackwardsOnwards »

Show Forum Drop Down Menu