Javascript

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJavascript

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old August 23rd, 2007, 02:31 AM
thunder's Avatar
thunder thunder is offline
Moderator
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 446 thunder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 7 h 33 m 20 sec
Reputation Power: 12
Send a message via MSN to thunder Send a message via Google Talk to thunder
Javascript Password Prompt

I would like to put a password box on my forum, problem is, this forum only lets me access one lot of code, which the whole site is run off... So I use my basic javascript password script:

Code:
<script language="JavaScript" type="text/javascript">
<!--hide

var password;
var pass1="hello";
password = prompt('Enter your password in order   to view this page!', ' ');
if (password == pass1) {
alert('YAY you got it right! Click OK to enter!');
} else {
window.location = "http://www.google.com";
}
}
//-->
</script>


It works fine, but it asks for the password on every page you enter, which for obvious reasons is un-desireable. So my IT teacher suggested making an if statement:

Code:
<script language="JavaScript" type="text/javascript">
<!--hide
var allowed = false;
var password;
var pass1="hello";
if (allowed == false) {
password = prompt('Enter your password in order   to view this page!', ' ');
if (password == pass1) {
alert('YAY you got it right! Click OK to enter!');
allowed = true;
} else {
window.location = "http://www.google.com";
}
} else if (allowed == true) {
alert('You have already entered the password. Click OK to enter!');
}
//-->
</script>


Unfortunately, this doesn't work... Now I'm no whizz at Javascript... But I am fairly good with Flash... And the IF/ else statements look fairly similair...

Thanks for all your help.
__________________
Flash and HTML nut.

Hey. Learn how to wite XHTML, stop using dreamweaver! =)

Contact me at:
Send a mesage to John Doe


Reply With Quote
  #2  
Old August 23rd, 2007, 02:57 PM
_Kenny_Programing_'s Avatar
_Kenny_Programing_ _Kenny_Programing_ is offline
~Moderator~
Click here for more information
 
Join Date: Feb 2006
Location: Ohio
Posts: 640 _Kenny_Programing_ New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 3 Days 2 h 10 m 3 sec
Reputation Power: 0
Send a message via MSN to _Kenny_Programing_ Send a message via Skype to _Kenny_Programing_ Send a message via XFire to _Kenny_Programing_
well, you could use the IF or you can just edit the javascript to prompt once for login and not over and over, go to www.javascript.com to learn more and research some of the codes they have and you will figure it out
__________________
Never judge a book by its cover.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJavascript > Javascript Password Prompt


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap