473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need a little help here... (dont we all?) i need to refrence a var in two scripts....

eragon
431 256MB
I am making a password script, i have most of it done, ill show you, but i hit a brick wall.... lol, I have it so when you log in it takes you to your main page, that works, but when you enter the wrong info, it's supposed to say "Invalid Username or Password" below the login boxes. (Using the document.write command), but to do this, i need to refrence the main script to get the yes or no if they logged in right.... i need help.... im using inernet explorer v6.0, heres my script:

This is my external .js file (name is pass.js):

Expand|Select|Wrap|Line Numbers
  1. <!-- Begin
  2. function Login() {
  3. var error="No Errors";
  4. var done=0;
  5. var username=document.login.username.value;
  6. username=username.toLowerCase();
  7. var password=document.login.password.value;
  8. password=password.toLowerCase();
  9. //User info//
  10. if (username=="eragon" && password=="password") { window.location="pages/eragon.htm"; done=1; }
  11. //End User Info//
  12. if (done==0) { error="Incorrect Username or Password"; }
  13. }
  14. // End -->
Ok, that was my external .js file, now heres my web page sorce code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>login</title>
  4. <script language="javascript" src="pass.js">
  5. </head>
  6. <body>
  7. <form name="login">
  8. <input type="text" name="username">
  9. <input type="password" name="password">
  10. <input type="button" value="login" onClick="login()">
  11. </form>
  12. <!-- This is the part i need help with: -->
  13. <script language="Javascript">{ document.write (error);  }</script>
  14. </body>
  15. </html>
So, you saw my scripts, i would appreciate it if you test them, and tell me anything that is wrong.... thanks much, nice people...


Yours thankfully,

Eragon Eisert
Mar 27 '07 #1
5 1698
r035198x
13,262 8TB
I am making a password script, i have most of it done, ill show you, but i hit a brick wall.... lol, I have it so when you log in it takes you to your main page, that works, but when you enter the wrong info, it's supposed to say "Invalid Username or Password" below the login boxes. (Using the document.write command), but to do this, i need to refrence the main script to get the yes or no if they logged in right.... i need help.... im using inernet explorer v6.0, heres my script:

This is my external .js file (name is pass.js):

Expand|Select|Wrap|Line Numbers
  1. <!-- Begin
  2. function Login() {
  3. var error="No Errors";
  4. var done=0;
  5. var username=document.login.username.value;
  6. username=username.toLowerCase();
  7. var password=document.login.password.value;
  8. password=password.toLowerCase();
  9. //User info//
  10. if (username=="eragon" && password=="password") { window.location="pages/eragon.htm"; done=1; }
  11. //End User Info//
  12. if (done==0) { error="Incorrect Username or Password"; }
  13. }
  14. // End -->
Ok, that was my external .js file, now heres my web page sorce code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>login</title>
  4. <script language="javascript" src="pass.js">
  5. </head>
  6. <body>
  7. <form name="login">
  8. <input type="text" name="username">
  9. <input type="password" name="password">
  10. <input type="button" value="login" onClick="login()">
  11. </form>
  12. <!-- This is the part i need help with: -->
  13. <script language="Javascript">{ document.write (error); }</script>
  14. </body>
  15. </html>
So, you saw my scripts, i would appreciate it if you test them, and tell me anything that is wrong.... thanks much, nice people...


Yours thankfully,

Eragon Eisert
Java != Javascript.

Moved to javascript forum.
Mar 27 '07 #2
acoder
16,027 Expert Mod 8TB
You can't write to the page using document.write() after the page has loaded.

Have a div or a span on the page:
Expand|Select|Wrap|Line Numbers
  1. <div id="errors"></div>
then in your login function at the end:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("errors").innerHTML=error;
Also, the case must be the same for the function names - you can't use login and Login interchangeably.
Mar 27 '07 #3
eragon
431 256MB
it works great! my internet was down so i couldnt post right away, but i tried the script and it works great... just one more question... how do i get the error to only appear if the information is unvalid. I need this because the error message appears every time while the next page is loading. Thank you all for your help!
Apr 9 '07 #4
acoder
16,027 Expert Mod 8TB
When you run your login function, if there are no errors, set the errors variable to an empty string. Then set the div to remove the error message.
Apr 10 '07 #5
eragon
431 256MB
i got it all working, thanks... i have another topic i need help with, look for my other thread called "Simple edit... or is it? Help Me!!!" and look at the description...
May 23 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: nightsaber | last post by:
<script language="JavaScript"> <!-- hide me var the_number = prompt("how many words (3-5 is good)?", "4"); var the_string = ""; var a_word; for (loop = 0; loop < the_number; loop++) {...
11
by: Jack | last post by:
I have a asp form where among others there are few text boxes and one check box. The checkbox is to indicate whether the entry is final. The checkbox is attahced to a field in table of type...
7
by: Tee | last post by:
Hi, I need some help here for DSN connection string. I know it's not recommended to use DSN, even I dont like it as well ... but for now, my situation is I am using a shared hosting. I do not...
5
by: JustSomeGuy | last post by:
According to the docs... http://www.cppreference.com/cpplist/sort.html There is a parameter to the std::list.sort method. I don't understand this methods use... I want to sort the list which...
13
by: gavino | last post by:
This seems easy but I have been asking tcl and python IRC chat all day and no one gave an answer. I have 100 servers which need a new backup server added to a text file, and then the backup agent...
12
by: nephish | last post by:
Hello there, i am getting to need to make my web stuff more OO. i have a project at work that we are porting to the internet, and i started learning php to do so. the project is now mamoth is...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
0
by: Jorhajnes | last post by:
Hi there. Im very new to making games in flash, although I have used flash for quite some time now in web-based situations so I know my way around. Anyways, I thought it would be fun to try...
5
by: Chuck Anderson | last post by:
I run Apache 2.0.55, and Php (both 4.4.1 and 5.2.5) on my home PC (Windows XP). One of the scripts that I run daily needs to access a secure URL (https://..............). When I am running Php4,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.