| | |
"<SCRIPT SRC>" javascript logon help
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Ok, ive created a login script and i have saved it as login.js. See below:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="someone" && password=="something") { window.location="page.htm"; done=1; }
if (done==0) { alert("Invalid login! (try lower case)"); }
}
// End -->
</SCRIPT>
<text>
<center>
<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Secure Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username size="20"></td></tr>
<tr><td>Password:</td><td><input type=password name=password size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login!" onClick="Login()"></td></tr>
</table>
</form>
</center>
</text>
I have added the following to the page on which the login script should appear:
<SCRIPT SRC="login.js" language="JavaScript/text">
</SCRIPT>
The script its self works, but it does not work from the login.js file. What am i doing wrong?
Greatful for any help you can give me,
NuGG
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="someone" && password=="something") { window.location="page.htm"; done=1; }
if (done==0) { alert("Invalid login! (try lower case)"); }
}
// End -->
</SCRIPT>
<text>
<center>
<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Secure Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username size="20"></td></tr>
<tr><td>Password:</td><td><input type=password name=password size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login!" onClick="Login()"></td></tr>
</table>
</form>
</center>
</text>
I have added the following to the page on which the login script should appear:
<SCRIPT SRC="login.js" language="JavaScript/text">
</SCRIPT>
The script its self works, but it does not work from the login.js file. What am i doing wrong?
Greatful for any help you can give me,
NuGG
have you tried debugging it with an alert (to make sure the HTML is importing the script?) something like: alert("made it to such and such function"); and stick that in a function in the external.js file, and then in your HTML code, when you call the function (that is supposed to be in the external.js file) it should come up with an alert. This way, you know the browser is actually retrieving the javascript code.
just a question though...does it matter to have the src="location of script" then?type="text/javascript"
also, have you tried removing the actualy <script tags from it? i know that when i went to do what your doing but for an image swap program, that i had to remove the <script> and </script> from the script itself and save it to its own JS file, before that i was having issues getting it to work.
also, have you tried removing the actualy <script tags from it? i know that when i went to do what your doing but for an image swap program, that i had to remove the <script> and </script> from the script itself and save it to its own JS file, before that i was having issues getting it to work.
Dont forget to spread the reputation to those that deserve!
![]() |
Similar Threads
- how to change the the value of src in <embed> using javascript (JavaScript / DHTML / AJAX)
- <script language=\"javascript\"> Display problem with PHP & MYSQL (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: "make Us Your Homepage" Script ?
- Next Thread: Javascript printing
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp ajaxjspservlets animate api automatically blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element engine events explorer ext file firehose flash form forms game gears google gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft mp3 mysql object offline onerror onmouseoutdivproblem onreadystatechange parent passing pdf php player post progressbar rated regex runtime scroll search security session shopping size software solutions sql star stars stretch synchronous text textarea twitter validation web website window windowsxp wysiwyg xspf \n





