Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Wednesday, October 19th, 2005

Time Event
5:29p
Hello all! Short introduction; My name is sam, I'm 17 years of age from the UK. I've been using html in web design for over a year now, and have just taken the plunge and decided to teach myself javascript. So yeah, I'm a total beginner at the moment. Anyway, on with the post...

for a friends website, I wanted something that would allow you to input data, but have it under password protection, so I quickly scripted the following code


function imp()
{
var psswrd = prompt("password","type here")
if(psswrd="elephant")
{
var cheese = prompt("enter variable","here")
}
else
{
alert("WRONG PASSWORD")
}
document.write(cheese)
}

All seems fine I thought, however after testing I discovered that you can type anything in the password prompt, and still be allowed to enter the variable (Which is meant to be password protected). To find out what was going on, I simply inserted 'document.write(psswrd)' to find that the script is infact assigning 'elephant' to password somehow. I haven't a clue what I've done wrong.

any help would be greatly appreciated

sam

<< Previous Day 2005/10/19
[Calendar]
Next Day >>
About LiveJournal.com
Image