Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2003, 01:01 AM
kip kip is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I get all these functions to work together

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").getElementsByTag Name("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"><strong>Username:</strong></div>
        </td>
        <td>
         <input type=text name=username size=20>
        </td>
     </tr>
     <tr>
        <td><div align="right"><strong>Password:</strong></div>
        </td>
        <td>
         <input type=password name=password size=20>
        </td>
     </tr>
     <tr>
        <td>&nbsp;</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>
 
Old August 6th, 2003, 02:41 PM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to troyologist
Default

IM NOT SURE IF THIS ONES GONNA WORK... TRY IT,

<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").getElementsByTag Name("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()" onLoad="EnterHandler(oElm)" onLoad="Login(form)" 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"><strong>Username:</strong></div>
        </td>
        <td>
          <input type=text name=username size=20>
        </td>
      </tr>
      <tr>
        <td><div align="right"><strong>Password:</strong></div>
        </td>
        <td>
          <input type=password name=password size=20>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</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>


:D bloody_thief® and liQuid_iMager®,
:D making things a lil bit simple.






Similar Threads
Thread Thread Starter Forum Replies Last Post
C# functions daniel.mihalcea C# 2008 aka C# 3.0 3 September 11th, 2008 05:10 PM
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
C functions...??? ethantinder C# 2 April 25th, 2008 02:25 AM
Functions LTello BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 September 15th, 2006 11:15 AM
functions xelepi PHP How-To 1 March 10th, 2006 02:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.