Click to See Complete Forum and Search --> : mighty ones what do some commands mean var if location how do i use them


scottec
02-25-2003, 01:40 PM
oh mighty ones reveal to me a website where
i can find definitions for commands such as if var ect
if there is a web site please tell me
also help me with my web site i cannot figure
out how do i make them go to alert htm for evry individual failed password

http://www.angelfire.com/theforce/scottec/


var password = 'billbo'
password=prompt('who gave frodo the one ring ?:','');
if (password != 'billbo') {
location.href= "alert.htm";
}
var password = 'gaffer'
password=prompt('who did sam talk about often:','');
if (password != 'gaffer') {
location.href= "alert.htm";


http://www.angelfire.com/theforce/scottec/

Charles
02-25-2003, 01:53 PM
http://developer.netscape.com/docs/manuals/js/client/jsref/contents.htm

AdamBrill
02-25-2003, 01:57 PM
One other thing about your site is anyone can click view source and get all the answers. Just thought I would point it out... ;)

scottec
02-25-2003, 01:58 PM
Charles





thank you can you help with my scripting............... if you hit cancle on the password it does not count aganst you ........................can it ?

i want to send them to alert.htm

scottec
02-25-2003, 02:00 PM
AdamBrill

oh great supreme being
the way i set it up it seemed to not do that it does not give you an openig to hit veiw sorce does it ?

AdamBrill
02-25-2003, 02:17 PM
Well, after you answer all of the questions, if they click view source before the next page loads, then they can see all of the answers. But, here is a simple piece of code that you might be interested in:
<script language=javascript>
questions = new Array("who gave frodo the one ring ?:",
"who did sam talk about often:");
answers = new Array("bilbo",
"gaffer");
x=0;
correct=0;
incorrect=0;
password=null;
do
{
password=prompt(questions[x],"")
if(password.toLowerCase()==answers[x])
{
correct++;
}else{
incorrect++;
}
x++;
} while(x<questions.length)
</script>
This won't help the view source problem, but it makes it keep track of how many they get right and wrong. If you just put all of the questions and answers in the array, then it will just run the do...while loop until it is done. The correct variable will tell how many they got right and the incorrect will tell how many they got wrong. When you put the answers in, put them in lowercase; that way it doesn't matter if they capitalize it the same way you did. I hope this helps. :)

AdamBrill
02-25-2003, 02:24 PM
oops... In this line:

if(password.toLowerCase()==answers[x])

It should be:

if(password!=null && password.toLowerCase()==answers[x])

That way it doesn't cause an error if they cancel...

scottec
02-25-2003, 02:36 PM
adam brill

thank you very much
thats exactly what i wanted to know

so if i had more questions (qs) and ansewers(as) it would be

q1,q2,q3,

a1,a2,a3,

like that ?

Nevermore
02-25-2003, 03:20 PM
To get past javascript password protectiom:

Turn off javascript
view source
Turn on javascript
input password

AdamBrill
02-25-2003, 03:58 PM
scotttec - Yup. Just like that. Like I said before, though, enter all of your answers in lower case.

scottec
02-25-2003, 04:18 PM
oh I see