Click to See Complete Forum and Search --> : How can I get these Functions to work together?


kip
08-03-2003, 02:06 PM
List,

How can I get these functions to work together?


<html>
<head>
<title>FTP login</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
//
// This Function sets the 'Usernsme' feild into focus.
//
function toForm() {
document.login.username.focus();
}
//
// This Function makes sure both of the feilds are filled out, otherwise an 'Alert' will pop up to alert them to fill them out.
// Please enter your "ftpserver.com" address in the 'var ftpsite' line of code.
//
function Login(form) {
____var username = form.username.value;
____var password = form.password.value;
____if (username && password) {
________var ftpsite = "ftp://" + username + ":" + password + "@" + "ftpServer.com";
________window.location.href = ftpsite;
____} else {
________alert("Please enter your username, and password.");
____}
}
</script>
<script language=3D"Javascript">
//
// This function allows the "Enter" key to submit the form.
//
// I know the input feilds do not have the right naming convention to utilize this Function.
// This is where I am drawing a blank.
// I am trying to validate the form to make sure that both feilds are filled in, otherwise alert.
//
function EnterHandler(oElm) {
____if(event.keyCode =3D=3D 13){
____var intNewIndexFocus =3D parseInt(oElm.getAttribute("indexNo"), 10) + 1;
____var arrInputFields =3D
____document.getElementById("myform").getElementsByTagName("input");
________for(var i=3D0; i<arrInputFields.length; i++){
____________var oInput =3D arrInputFields[i];
____________if(oInput.getAttribute("type") =3D=3D ="text" && parseInt(oInput.getAttribute("indexNo"), 10) =3D=3D = intNewIndexFocus) {
________________oInput.focus();
_____________}
________}
________event.returnValue =3D false;
____}
}____
</script>
</head>
<body__onLoad="toForm()" bgcolor="#660000" text="#FFFFFF" link="#FFFFFF" vlink="#CCCCCC" alink="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
__<form name=login>
____<br>
____<br>
____<table width=300 border=1 align="center" bordercolor="#993300">
______<tr bgcolor="#993300">
________<td height="60" colspan=2 align=center><b>
__________<h2>&nbsp;__________</h2>
__________</b></td>
______</tr>
______<tr>
________<td><div align="right"><font color="#FFFFFF" size="1" face="Arial"><strong>Username:</strong></font></div>
________</td>
________<td>
__________<input type=text name=username size=20>
________</td>
______</tr>
______<tr>
________<td><div align="right"><font color="#FFFFFF" size="1" face="Arial"><strong>Password:</strong></font></div>
________</td>
________<td>
__________<input type=password name=password size=20>
________</td>
______</tr>
______<tr>
________<td><font color="#FFFFFF" size="1" face="Arial">&nbsp;</font></td>
________<td><input name="button" type="button" onClick="Login(this.form)" value="Submit">
__________<input type="reset" name="Reset" value="Reset">
________</td>
______</tr>
______<tr>
________<td colspan=2 align=center><p>&nbsp;</p>
________</td>
______</tr>
____</table>
__</form>
</center>
</body>
</html>

AdamBrill
08-03-2003, 05:33 PM
What are you trying to do? Is the second function only to get the form to work on the enter key? If so, use this instead:<html>
<head>
<title>FTP login</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
//
// This Function sets the 'Usernsme' feild into focus.
//
function toForm() {
document.login.username.focus();
}
//
// This Function makes sure both of the feilds are filled out, otherwise an 'Alert' will pop up to alert them to fill them out.
// Please enter your "ftpserver.com" address in the 'var ftpsite' line of code.
//
function Login(form) {
var username = form.username.value;
var password = form.password.value;
if (username && password) {
var ftpsite = "ftp://" + username + ":" + password + "@" + "ftpServer.com";
window.location.href = ftpsite;
} else {
alert("Please enter your username, and password.");
}
}
</script>
</head>
<body onLoad="toForm()" bgcolor="#660000" text="#FFFFFF" link="#FFFFFF" vlink="#CCCCCC" alink="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<form name=login>
<br>
<br>
<table width=300 border=1 align="center" bordercolor="#993300">
<tr bgcolor="#993300">
<td height="60" colspan=2 align=center><b>
<h2>
</h2>
</b>
</td>
</tr>
<tr>
<td><div align="right"><font color="#FFFFFF" size="1" face="Arial"><strong>Username:</strong></font></div>
</td>
<td>
<input type=text name=username size=20>
</td>
</tr>
<tr>
<td><div align="right"><font color="#FFFFFF" size="1" face="Arial"><strong>Password:</strong></font></div>
</td>
<td>
<input type=password name=password size=20>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="1" face="Arial"> </font></td>
<td><input name="button" type="submit" onClick="Login(this.form);return false;" value="Submit">
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
<tr>
<td colspan=2 align=center><p> </p>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

kip
08-03-2003, 09:32 PM
Thanks a bunch! I am an idiot... but there seems to be one problem in IE, when you hit the 'Back' button, you can enter in any password you would like and hit the 'Enter/ Return' Key and the form will return you to the last directory you were in.

Is there a way to perge the variables values when anytime the page refreshes? Is there a way to have the page NEVER cache?

Thanks so much for your HELP.

-Kip