help javascript program

Giganews Newsgroups
Subject: help javascript program
Posted by:  f700b (n…@whsnet.ath.cx)
Date: 9 Jul 2005

I have the bellow javascript code.
I know the username and the password , and I like
to modify this code for login without press intro.
It is possible?.
Thanks

--------------------------------
<html>
<head>
<link rel="stylesheet" href="../html/css/alpha.css" type="text/css">
<script type='text/javascript' src="../html/js/alphaindex.js"></script>

<script Language="JavaScript">
function DoLogin()
{

document.formLogin.elements[2].value=document.usrInput.username.value;

document.formLogin.elements[3].value=document.usrInput.password.value;
  document.formLogin.submit();
}

var focusTarget=-999;
var focusButton;
var ns=(navigator.appName=="Netscape"?1:0);
var ver=parseInt(navigator.appVersion)
document.onkeydown=whichF;
if (ns)
{
  document.onmousedown=whichF;
  if (ver==4 || ver==5)
  {
      document.captureEvents(Event.KEYDOWN | Event.MOUSEDOWN);
  }
}

function whichF(e)
{
  focusButton=(ns?e.target.type:event.srcElement.type);
  if (ns)
  {
    focusTarget=e.which;
  }
  else
  {
    chkKey(e);
  }
}

function chkKey(e)
{
var chk=(ns?focusTarget:event.keyCode);
if (chk==13)
{
  DoLogin();
}
DoLogin();
}

</script>
</head>
<body>
<script type='text/javascript'>
    <!-- main table -->
    mainTableStart() ;
    <!-- header and logo area [ First row ] -->
    headerandlogo(1) ;
    <!-- Second Row -->
    secondRowStart() ;
    <!-- Left Area -->
    leftArea(0,0,0,0,1) ;
    <!-- content main table start -->
    contentMainTableStart() ;
    contentTableStart(0,1) ;
</script>

<!-- #bbinclude "index-main.html" -->

<!-- end bbinclude -->

<form method="POST"
action='http://192.168.1.1/cgi-bin/webcm?getpage=../html/status/syslog.htm'
name="formLogin">
            <input type="hidden" name="getpage"  value="../html/home.htm">
            <input type="hidden" name="errorpage" value="../html/index.html" >
            <input type="hidden" name="login:command/username" value="admin" >
            <input type="hidden" name="login:command/password" value="password"
>
    <input type="hidden" name="var:errormsg" value="Error">
</form>

<table width="540px" height="410" border="0" align="center"
bordercolor="#000000"    cellspacing="0" cellpadding="8">
    <tr>
        <td height="35" class="tabhead"><div align="left">Login</div></td>
    </tr>
    <tr>
        <td height="244" align="center" valign = "top">

        <form name="usrInput">
            <table width="100%" border="0" align="center" bordercolor="#000000"
cellspacing="0" cellpadding="5">
                <tr>
                      <td colspan="3" class="blubg">Please log in to continue
                      </td>
                 </tr>
                <tr>
                    <td width="5%" class="tabdata">&nbsp;
                    </td>
                    <td width="26%" class="tabdata">Login Name </td>
                    <td width="69%" class="tabdata"><input type="text" name="username"
maxlength="64" value="admin">
                    </td>
                </tr>
                <tr>
                    <td class="tabdata">&nbsp;
                    </td>
                    <td class="tabdata">Password </td>
                    <td width="69%" class="tabdata"><input type=password name=password
maxlength="64" value="password"></td>
                </tr>
                <tr>
                    <td colspan="2" class="tabdata">&nbsp;
                    </td>

                    <td width="69%" class="tabdata">

                    </td>

                </tr>
                <tr>
                    <td colspan="3" class="tabdata"><center><font color="red"
align=center>

                </font></center>
                    </td>
                </tr>
            </table>
        </form>
        </td>
    </tr>
----------------------------------------------------------

Replies