Solved

"Not an Object" error

Posted on 2001-07-23
34
268 Views
Last Modified: 2012-05-05
The code is supposed to store the username and password and then be able to regurgitate that data when asked.

I have this code, but it is giving me an error:
username not an object

Can anyone identify what I am doing wrong?

<script language="javascript" type="text/javascript">
     expireDate = new Date();
     expireDate.setMonth(expireDate.getMonth()+6);
     function getCookie() {
          form.username.value = cookieVal("userName");
          document.form.accountcode.value = cookieVal("accountCode");
          document.form.userpassword.value = cookieVal("userPassword");
          document.form.saveinfo.value = cookieVal("saveInfo");
     }
     function setCookie() {
          accountCode = this.form.accountcode.value;
          document.cookie = "accountCode="+accountCode+";expires="+expireDate.toGMTString();
          userName = this.form.username.value;
          document.cookie = "userName="+userName+";expires="+expireDate.toGMTString();
          userPassword = this.form.userpassword.value;
          document.cookie = "userPassword="+userPassword+";expires="+expireDate.toGMTString();
          saveInfo = this.form.saveinfo.value;
          document.cookie = "saveInfo="+saveInfo+";expires="+expireDate.toGMTString();
     }
     function cookieVal(cookieName) {
          thisCookie = document.cookie.split(";")
          for (i=0;i<thisCookie.length;i++) {
               if (cookieName == thisCookie[i].split("=")[0]) {
                    return thisCookie[i].split("=")[1]
               }
          }
          return 0
     }
</script>

<script language="JavaScript">
<!--// Beginning of Script
     getCookie();
  if (screen.width <= 800)
  {
    document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
  }
  else
  {
     document.write('<TABLE WIDTH="784" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
  }
// End of Script -->
</SCRIPT>
0
Comment
Question by:thocutt
  • 13
  • 11
  • 8
  • +1
34 Comments
 
LVL 7

Expert Comment

by:daniel_c
ID: 6309594
Just guessing, I think this is a case-sensitive issue:
form.username.value --> Make sure that in your form,
<input type=text name=username> is all in lower case, because Javascript is case sensitive.

Hopefully that helps!
0
 

Author Comment

by:thocutt
ID: 6309672
On the form every thing looks to be lower case, so I don't think that's the problem.

<tr>
<td class="formlabel" align="right">User Name :</td>
<td class="text" align="left">
<input type="text" class="tbox" size="12" name="username" id="username" value="<%=session("username")%>" onBlur="setCookie();">
</td>
</tr>
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6309779
What browser are you using?

We need to see the code for the ENTIRE page....some of the things I would suggest checking whilst waiting for the script:

1 - Do you have opening and closing <form> tags?

2 - I notice you are using tables - make sure the <form> tags are outside the tables, not "mixed" with in them i.e.

<table>
<form>
<tr><td> ... </td></tr>
</table>

is NOT good code - it will cause you problems.

3 - I suspect this line (amongst others) is causing a problem:

userName = this.form.username.value;

The "this" has nothing to relate to. Use:

document.forms['formname'].username.value;


:o)

Ant
0
 

Author Comment

by:thocutt
ID: 6309885
Here's the code & I will try replacing  "this" with the form's name (which is "form").


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK rel="stylesheet" type="text/css" href="fms.css">
<script language="JavaScript" src="calendar.js"></script>
<script language="JavaScript" src="../fms.js"></script>
</HEAD>

<BODY>
<TABLE width="100%">
<TD width="1" class="text" valign="top">
<TD valign="top">
<CENTER><FONT face="Verdana, Arial" size="+1">Environmental Management System</FONT></CENTER>
<BR>      

<!--- Table Width Script --->

<script language="javascript" type="text/javascript">
      expireDate = new Date();
      expireDate.setMonth(expireDate.getMonth()+6);
      function getCookie() {
            form.username.value = cookieVal("userName");
            document.form.accountcode.value = cookieVal("accountCode");
            document.form.userpassword.value = cookieVal("userPassword");
            document.form.saveinfo.value = cookieVal("saveInfo");
      }
      function setCookie() {
            accountCode = this.form.accountcode.value;
            document.cookie = "accountCode="+accountCode+";expires="+expireDate.toGMTString();
            userName = form.form.username.value;
            document.cookie = "userName="+userName+";expires="+expireDate.toGMTString();
            userPassword = form.form.userpassword.value;
            document.cookie = "userPassword="+userPassword+";expires="+expireDate.toGMTString();
            saveInfo = form.form.saveinfo.value;
            document.cookie = "saveInfo="+saveInfo+";expires="+expireDate.toGMTString();
      }
      function cookieVal(cookieName) {
            thisCookie = document.cookie.split(";")
            for (i=0;i<thisCookie.length;i++) {
                  if (cookieName == thisCookie[i].split("=")[0]) {
                        return thisCookie[i].split("=")[1]
                  }
            }
            return 0
      }
</script>

<script language="JavaScript">
<!--// Beginning of Script
getCookie();
  if (screen.width <= 800)
  {
    document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
  }
  else
  {
     document.write('<TABLE WIDTH="784" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
  }
// End of Script -->
</SCRIPT>
<noscript>
  <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
</noscript>
<!--- End Table Width Script --->
      <tr><td>
      <P><FONT FACE="Arial,Helvetica" SIZE="2">Please enter your Client Number and Password to logon to
        <B>FarmHome</B>. If you do not have a Client Number and Password, please contact us
        on Freecall <NOBR><B>1800 xxx xxx</B></NOBR> 8am to 8pm (Western time) Monday to Friday.
        </FONT></P><br></TD>
      </TR>
      <tr>
      <br>


      <CENTER>
      <table width="50%" cellpadding="1" cellspacing="1" bgcolor="#0000FF">
            
                  <TR><TD align="center" class="tabletitle">Please Login</td></tr>
            
            <TR><TD>
                  <TABLE width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#EEEEEE">

      <form method="post" action="login.asp" id="form" name="form">
      <tr><td colspan="2">&nbsp;</td></tr>
      <tr>
            <td class="formlabel" align="right">Account Code :</td>
            <td class="text" align="left">
                  <input type="text" class="tbox" size="12" name="accountcode" id="accountcode" value="FARM" onBlur="setCookie();">
            </td>
      </tr>
      <tr>
            <td class="formlabel" align="right">User Name :</td>
            <td class="text" align="left">
                  <input type="text" class="tbox" size="12" name="username" id="username" value="GREG" onBlur="setCookie();">
            </td>
      </tr>
      <tr>
            <td class="formlabel" align="right">Password :</td>
            <td class="text" align="left">
                  <input type="password" class="tbox" size="12" name="userpassword" id="userpassword" value="IWM" onBlur="setCookie();">
            </td>
      </tr>
      <tr><td colspan="2" align="center">&nbsp;
            <input type="checkbox" checked name="saveinfo" onBlur="setCookie();">Remember My Details
      </td></tr>
      <tr><td colspan="2" align="center">
                  <input type="submit" class="fbutton" value="Login" name="submit" id="submit">
            </td>
      </tr>
      <tr><td colspan="2">&nbsp;</td></tr>
      </form>
      <SCRIPT language="javascript">
            document.form.accountcode.focus();
      </SCRIPT>

                  </TABLE>
            </TD></TR>
      </TABLE>
      </center>

    <p align="center">
      <br>
      <input type="checkbox" checked name="newinfo"><a href="farmhome-newinfo.asp">Show Farmhome New Features and Recent Changes</a>
      <br><br>
    <script LANGUAGE="JavaScript">
            if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
            var url="http://www.interglobalwaste.com/farmhome";
            var title="FarmHome.Com";
            document.write('<A HREF="javascript:window.ext');
            document.write('ernal.AddFavorite(url,title);" ');
            document.write('onMouseOver=" window.status=');
            document.write("'Add FarHome.Com To Your Favorites!'; return true ");
            document.write('"onMouseOut=" window.status=');
            document.write("' '; return true ");
            document.write('">Add FarmHome.Com To Your Favorites!</a>');
            }
            else {
                  var msg = "Be Sure To Bookmark FarmHome.Com By Selecting:  Netscape Users:";
                  if(navigator.appName == "Netscape") msg += "  CTRL-D; Opera Users:  CTRL-T";
                        document.write(msg);
            }
      </script></p>
<br>
      <tr>
      <td>&nbsp;</td>
      <TD><P><FONT FACE="Arial,Helvetica" SIZE="2"><B>Information on the security of your FarmHome service</B>
        <P>You are now within a secure <B>FarmHome</B> session using a 128 bit
        security key. The secure session is indicated by the padlock icon in the
        status bar at the bottom of the browser window. All data transmitted during
        your <B>FarmHome</B> session will be encrypted.
      <P></FONT></P></TD>
      </tr>

        <hr>
  <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
            <TR>
              <TD colspan="5">
                <P align="center"><b><font face="Arial, Helvetica, sans-serif" size="3"><FONT color="#009966">InterGlobal
                  Waste Management Inc.</FONT><BR>
                </font>
                  <FONT color="#333399">820 Calle Plano Ave Camarillo CA 93012
                  USA<BR>
                  Tel.
                  <FONT color="black">(805) 388-1588</FONT> Fax. <FONT color="black">(805)
                  388-0667</FONT></FONT></b><FONT face="Arial, Helvetica, sans-serif"><B><FONT color="#333399">email:
                </FONT>
                <FONT color="#FF9900">
                <A href="mailto: farminfo@interglobalwaste.com">farminfo@interglobalwaste.com</A>
                </FONT>
                </B>
                </FONT>
                                    <br> <br>
                </P>
              </TD>
            </TR>
            <TR align="center">
              <TD colspan="5" height="10">
                <DIV align="center"><FONT face="Arial, Helvetica, sans-serif" size="1"><B><FONT color="#009966"><A href="/farmhome/farmhome3.asp">Homepage</A></FONT></B></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A href="/farmhome/admin/company-info.htm">Company Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A href="/farmhome/admin/privacy.htm">Privacy Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A href="/farmhome/admin/copyright.htm">Copyright Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A href="/farmhome/admin/terms.htm">Terms_Conditions</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A href="/farmhome/farmhome-contactus.asp">Contact Us</A></FONT>
</DIV>
              </TD>
            </TR>
          </TABLE>
<center>
<p><b><font face="arial, geneva" size="-2">Copyright ? 2001 InterGlobal Waste
Management Inc. All Rights Reserved.
Any Problems? E-mail the <a href="mailto:webmaster@interglobalwaste.com">webmaster@interglobalwaste.com</a>.
<font face="Arial, Geneva" size="-2"></font></font></b><br>
<b><font face="arial, geneva" size="-2">If you are experiencing any viewing
problems, please download at least version 5.0 of either <a href="http://www.microsoft.com/ie/download/">Microsoft Explorer</a> or 6.0 <a href="http://www.home.netscape.com">Netscape Navigator</a>.</font></b></p>
</center>

                  </TABLE>
            </TD></TR>
      </TABLE>
      </center>

</TD>
</TR>
</TABLE>
</BODY>
</HTML>

0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6309921
There are a whole number of issues here.

For starters you are doing what I mentioned in my last comment you should NOT do:


               <TABLE width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#EEEEEE">

     <form method="post" action="login.asp" id="form" name="form">
     <tr><td colspan="2">&nbsp;</td></tr>



:oP

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6309930
You're also calling your form, "form".....not a good idea.

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6309936
Give this a try:



<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK rel="stylesheet" type="text/css" href="fms.css">
<script language="JavaScript" src="calendar.js"></script>
<script language="JavaScript" src="../fms.js"></script>
</HEAD>

<BODY>
<TABLE width="100%">
<TD width="1" class="text" valign="top">
<TD valign="top">
<CENTER><FONT face="Verdana, Arial" size="+1">Environmental Management System</FONT></CENTER>
<BR>    

<!--- Table Width Script --->

<script language="javascript" type="text/javascript">
     expireDate = new Date();
     expireDate.setMonth(expireDate.getMonth()+6);
     function getCookie() {
          document.forms['form1'].username.value = cookieVal("userName");
          document.forms['form1'].accountcode.value = cookieVal("accountCode");
          document.forms['form1'].userpassword.value = cookieVal("userPassword");
          document.forms['form1'].saveinfo.value = cookieVal("saveInfo");
     }
     function setCookie() {
          accountCode = document.forms['form1'].accountcode.value;
          document.cookie = "accountCode="+accountCode+";expires="+expireDate.toGMTString();
          userName = document.forms['form1'].username.value;
          document.cookie = "userName="+userName+";expires="+expireDate.toGMTString();
          userPassword = document.forms['form1'].userpassword.value;
          document.cookie = "userPassword="+userPassword+";expires="+expireDate.toGMTString();
          saveInfo = document.forms['form1'].saveinfo.value;
          document.cookie = "saveInfo="+saveInfo+";expires="+expireDate.toGMTString();
     }
     function cookieVal(cookieName) {
          thisCookie = document.cookie.split(";")
          for (i=0;i<thisCookie.length;i++) {
               if (cookieName == thisCookie[i].split("=")[0]) {
                    return thisCookie[i].split("=")[1]
               }
          }
          return 0
     }
</script>

<script language="JavaScript">
<!--// Beginning of Script
getCookie();
 if (screen.width <= 800)
 {
   document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
 }
 else
 {
    document.write('<TABLE WIDTH="784" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
 }
// End of Script -->
</SCRIPT>
<noscript>
 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
</noscript>
<!--- End Table Width Script --->
     <tr><td>
     <P><FONT FACE="Arial,Helvetica" SIZE="2">Please enter your Client Number and Password to logon
to
       <B>FarmHome</B>. If you do not have a Client Number and Password, please contact us
       on Freecall <NOBR><B>1800 xxx xxx</B></NOBR> 8am to 8pm (Western time) Monday to Friday.
       </FONT></P><br></TD>
     </TR>
     <tr>
     <br>


     <CENTER>
     <table width="50%" cellpadding="1" cellspacing="1" bgcolor="#0000FF">
         
               <TR><TD align="center" class="tabletitle">Please Login</td></tr>
         
          <TR><TD>
     <form method="post" action="login.asp" id="form1" name="form1">
               <TABLE width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#EEEEEE">

     <tr><td colspan="2">&nbsp;</td></tr>
     <tr>
          <td class="formlabel" align="right">Account Code :</td>
          <td class="text" align="left">
               <input type="text" class="tbox" size="12" name="accountcode" id="accountcode" value="FARM" onBlur="setCookie();">
          </td>
     </tr>
     <tr>
          <td class="formlabel" align="right">User Name :</td>
          <td class="text" align="left">
               <input type="text" class="tbox" size="12" name="username" id="username" value="GREG" onBlur="setCookie();">
          </td>
     </tr>
     <tr>
          <td class="formlabel" align="right">Password :</td>
          <td class="text" align="left">
               <input type="password" class="tbox" size="12" name="userpassword" id="userpassword" value="IWM" onBlur="setCookie();">
          </td>
     </tr>
     <tr><td colspan="2" align="center">&nbsp;
          <input type="checkbox" checked name="saveinfo" onBlur="setCookie();">Remember My Details
     </td></tr>
     <tr><td colspan="2" align="center">
               <input type="submit" class="fbutton" value="Login" name="submit" id="submit">
          </td>
     </tr>
     <tr><td colspan="2">&nbsp;</td></tr>
     <SCRIPT language="javascript">
          document.forms['form1'].accountcode.focus();
     </SCRIPT>

               </TABLE>
     </form>
          </TD></TR>
     </TABLE>
     </center>

   <p align="center">
     <br>
     <input type="checkbox" checked name="newinfo"><a href="farmhome-newinfo.asp">Show Farmhome New Features
and Recent Changes</a>
     <br><br>
   <script LANGUAGE="JavaScript">
          if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
{
          var url="http://www.interglobalwaste.com/farmhome";
          var title="FarmHome.Com";
          document.write('<A HREF="javascript:window.ext');
          document.write('ernal.AddFavorite(url,title);" ');
          document.write('onMouseOver=" window.status=');
          document.write("'Add FarHome.Com To Your Favorites!'; return true ");
          document.write('"onMouseOut=" window.status=');
          document.write("' '; return true ");
          document.write('">Add FarmHome.Com To Your Favorites!</a>');
          }
          else {
               var msg = "Be Sure To Bookmark FarmHome.Com By Selecting:  Netscape Users:";
               if(navigator.appName == "Netscape") msg += "  CTRL-D; Opera Users:  CTRL-T";
                    document.write(msg);
          }
     </script></p>
<br>
     <tr>
     <td>&nbsp;</td>
     <TD><P><FONT FACE="Arial,Helvetica" SIZE="2"><B>Information on the security of your FarmHome service</B>
       <P>You are now within a secure <B>FarmHome</B> session using a 128 bit
       security key. The secure session is indicated by the padlock icon in the
       status bar at the bottom of the browser window. All data transmitted during
       your <B>FarmHome</B> session will be encrypted.
     <P></FONT></P></TD>
     </tr>

       <hr>
 <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
           <TR>
             <TD colspan="5">
               <P align="center"><b><font face="Arial, Helvetica, sans-serif" size="3"><FONT color="#009966">InterGlobal
                 Waste Management Inc.</FONT><BR>
               </font>
                 <FONT color="#333399">820 Calle Plano Ave Camarillo CA 93012
                 USA<BR>
                 Tel.
                 <FONT color="black">(805) 388-1588</FONT> Fax. <FONT color="black">(805)
                 388-0667</FONT></FONT></b><FONT face="Arial, Helvetica, sans-serif"><B><FONT color="#333399">email:
               </FONT>
               <FONT color="#FF9900">
               <A href="mailto: farminfo@interglobalwaste.com">farminfo@interglobalwaste.com</A>
               </FONT>
               </B>
               </FONT>
                              <br> <br>
               </P>
             </TD>
           </TR>
           <TR align="center">
             <TD colspan="5" height="10">
               <DIV align="center"><FONT face="Arial, Helvetica, sans-serif" size="1"><B><FONT color="#009966"><A
href="/farmhome/farmhome3.asp">Homepage</A></FONT></B></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A
href="/farmhome/admin/company-info.htm">Company Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A
href="/farmhome/admin/privacy.htm">Privacy Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A
href="/farmhome/admin/copyright.htm">Copyright Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A
href="/farmhome/admin/terms.htm">Terms_Conditions</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A
href="/farmhome/farmhome-contactus.asp">Contact Us</A></FONT>
</DIV>
             </TD>
           </TR>
         </TABLE>
<center>
<p><b><font face="arial, geneva" size="-2">Copyright ? 2001 InterGlobal Waste
Management Inc. All Rights Reserved.
Any Problems? E-mail the <a href="mailto:webmaster@interglobalwaste.com">webmaster@interglobalwaste.com</a>.
<font face="Arial, Geneva" size="-2"></font></font></b><br>
<b><font face="arial, geneva" size="-2">If you are experiencing any viewing
problems, please download at least version 5.0 of either <a href="http://www.microsoft.com/ie/download/">Microsoft Explorer</a> or 6.0 <a
href="http://www.home.netscape.com">Netscape Navigator</a>.</font></b></p>
</center>

               </TABLE>
          </TD></TR>
     </TABLE>
     </center>

</TD>
</TR>
</TABLE>
</BODY>
</HTML>


Ant
0
 

Author Comment

by:thocutt
ID: 6309988
I tried just a straight post of your code, but the error still pops up...

Line: 22
Char: 10
Error: 'document.forms.form1.username' is not an object

Hmmm.
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310057
that's a classic the problem is where you call the getCookie(); right there the page hasn't finished loading yet so you gotta make sure everything is loaded (this means your form is not there yet)

so what you have to do is :
onload=function() {getCookie()};

instead of just calling it stright

also remember is very bad practice to call any of your form elements with reserved words like: form submit reset and so on this will brake your code also name and id should never be the same

ciao
Y
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310064
What is in the files?

<script language="JavaScript" src="calendar.js"></script>
<script language="JavaScript" src="../fms.js"></script>


I'm particularly interested in what the fms.js file is.... is there any reference to the form in either of these .js files?

:o)

Ant
0
 
LVL 7

Expert Comment

by:daniel_c
ID: 6310070
Error: 'document.forms.form1.username' is not an object
--> Change document.forms.form1 into document.form1

Point goes to Ant (if it works!) - ^_^
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310072
Y_ee!!!!!

Please stop proposing answers on questions when your "answer" is NOT the 100% guaranteed, "no questions asked" solution!!

I wouldn't mind so much if you weren't doing it on almost every question I'm working on!!

Your comments are very welcome here - but just as that....comments!!

:o\

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310082
The adjusted code I posted works fine on my machine.

I'm using IE5.5 - what browser are you using?

By the way, please reject the proposed answer.

Ant
0
 

Author Comment

by:thocutt
ID: 6310100
I just rejected the answer because I think the other guys get upset when people post as answers.  I definitely appreciate the response, tho.
0
 

Author Comment

by:thocutt
ID: 6310108
I am using IE 5.5 too.

This is fms.js :

function mOvr(src,clrOver){
      if (!src.contains(event.fromElement)){
            src.style.cursor = 'hand';
            src.bgColor = clrOver;
      }
}
function mOut(src,clrIn){
      if (!src.contains(event.toElement)){
            src.style.cursor = 'default';
            src.bgColor = clrIn;
      }
}
function mClk(src){
      if(event.srcElement.tagName=='TD')
            src.children.tags('A')[0].click();
}

function PopHelp(label, msg){
      // Set up Page Colors & Table
      var s1 = "<TITLE>Information!</TITLE>" +
        "<BODY onBlur='self.focus()' BGCOLOR='ffffff'><TABLE BORDER=0><TR>" +
        "<TD WIDTH=90% HEIGHT=90 VALIGN=TOP ALIGN=LEFT>"+
        "<FONT SIZE=4>";
      var s2 = "<FONT COLOR='FF0000'><B>"+label+"</B></FONT><P>";
      var s3 = "</TD><TD WIDTH=10%> </TD></TR><TR><TD> </TD>"+
        "<TD VALIGN=TOP ALIGN=RIGHT>"+
        "<FORM><INPUT TYPE='BUTTON' VALUE='Close'" +
        "onClick='self.close()'>"  +
        "</FORM></TD></TR></TABLE></BODY>";
      popup = window.open("HELP","HELP","toolbar=no,location=no,status=no,menubar=no,resizable=no,height=360,width=500,scrollbars=no");
      popup.document.write(s1+s2+msg+s3);
      popup.document.close();
}

function popBLR(){
      top.location.href= 'blr_regscan.htm';
}

function SetShow(){
      session("varshow") = varshow;
}
<!-- -->

var max_cookies = 20; // no more than 20 cookies per server allowed
var cookie_name = new Array(max_cookies);

function getCookie( Name ) {
      var search = Name + "=";
      if( document.cookie.length > 0 ) { // if there are any cookies
            offset = document.cookie.indexOf( search );
            if( offset != -1 ) { // if cookie exists
                  offset += search.length;
                  // set index of beginning of value
                  end = document.cookie.indexOf(";", offset);
                  // set index of end of cookie value
                  if( end == -1 ) {
                        end = document.cookie.length;
                  }
                  return unescape( document.cookie.substring( offset, end ));
            }
      } else {
            return false;
      }
}

function set_cookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function get_all_cookies() {
      var cookie_jar = document.cookie;
      var my_cookies = cookie_jar.split(';');
      var crumbs;

      for( var x = 0; x < my_cookies.length; x++ ) {
            crumbs = my_cookies[x].split('=');
            if( crumbs[0] != "" ) {
                  cookie_name[x] = crumbs[0];
            }
      }
      return cookie_name.join(',');
}

function expiration(days) {
      var expires = new Date();
      var today = new Date();
      expires.setTime( today.getTime() + (1000*60*60*24*parseInt(days)) );
      return expires;
}


function ctrlPrint()
{
  print();
}

function display_date_greeting()
{
      var today = new Date();
      var pad = "";
      if(today.getMinutes() < 10){pad = "0"};
      var minutes = pad + today.getMinutes();
      var ampm="AM";
      var hours=today.getHours();
      if((today.getHours() >=12)){var ampm="PM"};
      if((today.getHours() >=13)){var hours = today.getHours()-12};
      if((today.getHours() >=8) && (today.getHours() <=11)){
      document.write("<font size=2 color=green face=Arial, Helvetica, sans-serif>Good Morning! - </font>")
      }
    if((today.getHours() >=12) && (today.getHours() <=16)){
      document.write("<font size=2 color=green face=Arial, Helvetica, sans-serif>Good Afternoon! - </font>")
      }    
      if((today.getHours() >=17) && (today.getHours() <=20)){
      document.write("<font size=2 color=green face=Arial, Helvetica, sans-serif>Good Evening! - </font>")
      }
    if((today.getHours() >=21) && (today.getHours() <=23)){
document.write("<font size=2 color=red face=Arial, Helvetica, sans-serif>Good Late Evening! - </font>")
}
    if((today.getHours() >=0) && (today.getHours() <=7)){
document.write("<font size=2 color=red face=Arial, Helvetica, sans-serif>Good Early Morning! - </font>")
}
}
function display_time_greeting()
{
      var today = new Date();
      var pad = "";
    if(today.getMinutes() < 10){pad = "0"}
      var ampm = "AM";
      var minutes = pad + today.getMinutes()
      var hours = today.getHours()
      if((today.getHours() >=12)){var ampm = "PM"};
      if((today.getHours() >=13)){var hours = today.getHours()-12};
      Date.prototype.getFullYear = getFullYear
      Date.prototype.getActualMonth = getActualMonth
      Date.prototype.getActualDay = getActualDay
      Date.prototype.getCalendarDay = getCalendarDay
      Date.prototype.getCalendarMonth = getCalendarMonth
      function getFullYear() {
            var n = this.getYear()
            if (n < 1000)
            n += 1900
            return n
      }
      function getActualMonth() {
            var n = this.getMonth()
            n += 1
            return n
      }
      function getActualDay() {
            var n = this.getDay()
            n += 1
            return n
      }
      function getCalendarDay() {
            var n = this.getDay()
            var dow = new Array(7)
            dow[0] = "Sunday"
            dow[1] = "Monday"
            dow[2] = "Tuesday"
            dow[3] = "Wednesday"
            dow[4] = "Thursday"
            dow[5] = "Friday"
            dow[6] = "Saturday"
            return dow[n]
      }
      function getCalendarMonth() {
            var n = this.getMonth()
            var moy = new Array(12)
            moy[0] = "January"
            moy[1] = "February"
            moy[2] = "March"
            moy[3] = "April"
            moy[4] = "May"
            moy[5] = "June"
            moy[6] = "July"
            moy[7] = "August"
            moy[8] = "September"
            moy[9] = "October"
            moy[10] = "November"
            moy[11] = "December"
            return moy[n]
      }
    document.write("<font face=arial, helvetica size=2>" + "It is " + hours + ":" + minutes + " " + ampm + " - " + today.getCalendarDay() + ", " + today.getCalendarMonth() + " " + today.getDate() + ", " + today.getFullYear() + " &nbsp; </font>") ;
}

// Browser Checker
function version_ok() {
      ver_str=navigator.appVersion;
      vers=ver_str.substring(0,1);
            if(vers>3 || navigator.appName == "Netscape") {
               return 1;
            }
            return 0;
      }
// Question Skipper
function skip_question(q,qname,o) {
      if(version_ok()) {
             if(document.the_form[qname].options[o].selected) {
           window.location.hash=q;
                     }
      }
}
// Email Validator
function email_check(){
      var email = document.the_form.email.value;
      var at = email.indexOf("@");            
      var space = email.indexOf(" ");
      var comma = email.indexOf(",");
      var dot = email.indexOf(".");
      var two_dots = email.indexOf("..");
      var length = email.length -1;
            if ((at == -1)||(at == 0)||(at == length)||(space != -1)||(comma != -1)||(two_dots != -1)||(dot == -1)||(dot == length)||(dot == 0))
            {
                  alert("Please enter a valid email address.");
                  document.the_form.email.focus();
                                                             }
            else {
                  document.the_form.submit();
            }
}
// Image Preloader
function Preload()
{
        var the_images = new Array('images/1.jpg','images/2.jpg','images/3.jpg','images/4.jpg','images/5.jpg');
        preloadImages(the_images);
}
function preloadImages(the_images_array) {
        for(loop = 0; loop < the_images_array.length; loop++)
        {
                var an_image = new Image();
                an_image.src = the_images_array[loop];
        }
}
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310113
a.marsh !!

sorry about the answer that was supposed to be a comment I'm new at this web site didn't know about that

any way settle this I tried your suggestion on changing to document.form1 and still it gives me the error is there any way you could repost the final working example?

thank you
Y

ps: again sorry I got you upset
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310125
If we are both using the same browser and you copied and pasted my code exactly, then I can't see why one of us would get an error and the other wouldn't.

:o\

Ant
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:Y_ee
ID: 6310131
a.marsh !!

sorry about the answer that was supposed to be a comment I'm new at this web site didn't know about that

any way settle this I tried your suggestion on changing to document.form1 and still it gives me the error is there any way you could repost the final working example?

thank you
Y

ps: again sorry I got you upset
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310138
Apology accepted - please rest assured that your input is greatly welcomed - it is better to post comments though - doesn't lock the question unnecessarily. :o)

I think I'll check the code on my machine once more and then upload it to my demo web site and then we can all try exactly the same copy.

:o)

Ant
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310142
a.marsh !!

sorry about the answer that was supposed to be a comment I'm new at this web site didn't know about that

any way settle this I tried your suggestion on changing to document.form1 and still it gives me the error is there any way you could repost the final working example?

thank you
Y

ps: again sorry I got you upset
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310155
sorry for the multiple posting my browser went crazy :P
I didn't know that a question gets locked if you give an answer I now totally understand the problem I created

ciao
Y
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310179
There is obviously an error elsewhere in the code, because if you change the <body> tag to this:

<BODY onload="alert(document.forms['form1'].username.value);">


You'll see the value GREG is displayed which proves the syntax for accessing the form is correct.

Now it is just a case of going through with a fine toothcomb and finding the error!

:oP

Ant
0
 

Author Comment

by:thocutt
ID: 6310182
I am using the browser IE 5.5 and I copied and pasted the code exactly, but I'm still getting the error.  
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310184
The problem may also be elsewhere - look at this code I copied and pasted from the script:


<BODY>
<TABLE width="100%">
<TD width="1" class="text" valign="top">
<TD valign="top">



Where's the <tr> tag? And the </td> tag?!?!?!

You need to tidy the whole page up!!!

Ant
0
 

Author Comment

by:thocutt
ID: 6310194
Good point.  I'm going to go through the code and see where the problem lies.
0
 
LVL 1

Accepted Solution

by:
Y_ee earned 200 total points
ID: 6310220
that would be more of a rendering issue than a javascript problem if you are still getting that error is just because the form is not there yet (i've run on that problem my self expecially if your page are serverside built)

a real quick test that you can do is to write getCookie like this :
function getCookie() {
         if (!document.form1) alert('not here yet!')
         else alert('here I am!')
         document.form1.username.value = cookieVal("userName");
         document.form1.accountcode.value = cookieVal("accountCode");
         document.form1.userpassword.value = cookieVal("userPassword");
         document.form1.saveinfo.value = cookieVal("saveInfo");
    }

now in the body tag add onload="getCookie()"

and you'll see what I'm talking about

so the solution at the problem are two either you call getCookie in the onload

or you move the piece of code after the closing </form>

hope this will help

ciao
Y
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310231
try this:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK rel="stylesheet" type="text/css" href="fms.css">
<script language="JavaScript" src="calendar.js"></script>
<script language="JavaScript" src="../fms.js"></script>

</HEAD>

<BODY onload="getCookie()">
<TABLE width="100%">
<TD width="1" class="text" valign="top">
<TD valign="top">
<CENTER><FONT face="Verdana, Arial" size="+1">Environmental Management System</FONT></CENTER>
<BR>    

<!--- Table Width Script --->

<script language="javascript" type="text/javascript">
    expireDate = new Date();
    expireDate.setMonth(expireDate.getMonth()+6);
    function getCookie() {
         document.form1.username.value = cookieVal("userName");
         document.form1.accountcode.value = cookieVal("accountCode");
         document.form1.userpassword.value = cookieVal("userPassword");
         document.form1.saveinfo.value = cookieVal("saveInfo");
    }

    function setCookie() {
         accountCode = document.form1.accountcode.value;
         document.cookie = "accountCode="+accountCode+";expires="+expireDate.toGMTString();
         userName = document.form1.username.value;
         document.cookie = "userName="+userName+";expires="+expireDate.toGMTString();
         userPassword = document.form1.userpassword.value;
         document.cookie = "userPassword="+userPassword+";expires="+expireDate.toGMTString();
         saveInfo = document.form1.saveinfo.value;
         document.cookie = "saveInfo="+saveInfo+";expires="+expireDate.toGMTString();
    }
    function cookieVal(cookieName) {
         thisCookie = document.cookie.split(";")
         for (i=0;i<thisCookie.length;i++) {
              if (cookieName == thisCookie[i].split("=")[0]) {
                   return thisCookie[i].split("=")[1]
              }
         }
         return 0
    }
</script>


<noscript>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
</noscript>
<!--- End Table Width Script --->
    <tr><td>
    <P><FONT FACE="Arial,Helvetica" SIZE="2">Please enter your Client Number and Password to logon

to
      <B>FarmHome</B>. If you do not have a Client Number and Password, please contact us
      on Freecall <NOBR><B>1800 xxx xxx</B></NOBR> 8am to 8pm (Western time) Monday to Friday.
      </FONT></P><br></TD>
    </TR>
    <tr>
    <br>


    <CENTER>
    <table width="50%" cellpadding="1" cellspacing="1" bgcolor="#0000FF">
         
              <TR><TD align="center" class="tabletitle">Please Login</td></tr>
         
         <TR><TD>
    <form method="post" action="login.asp" id="form1" name="form1">
              <TABLE width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="#EEEEEE">

    <tr><td colspan="2">&nbsp;</td></tr>
    <tr>
         <td class="formlabel" align="right">Account Code :</td>
         <td class="text" align="left">
              <input type="text" class="tbox" size="12" name="accountcode" id="accountcode" value="FARM"
onBlur="setCookie();">
         </td>
    </tr>
    <tr>
         <td class="formlabel" align="right">User Name :</td>
         <td class="text" align="left">
              <input type="text" class="tbox" size="12" name="username" id="username" value="GREG"
onBlur="setCookie();">
         </td>
    </tr>
    <tr>
         <td class="formlabel" align="right">Password :</td>
         <td class="text" align="left">
              <input type="password" class="tbox" size="12" name="userpassword" id="userpassword" value="IWM"
onBlur="setCookie();">
         </td>
    </tr>
    <tr><td colspan="2" align="center">&nbsp;
         <input type="checkbox" checked name="saveinfo" onBlur="setCookie();">Remember My Details
    </td></tr>
    <tr><td colspan="2" align="center">
              <input type="submit" class="fbutton" value="Login" name="submit" id="submit">
         </td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <SCRIPT language="javascript">
         document.forms['form1'].accountcode.focus();
    </SCRIPT>

              </TABLE>
    </form>
         </TD></TR>
    </TABLE>
    <script language="JavaScript">
<!--// Beginning of Script
getCookie();
if (screen.width <= 800)
{
  document.write('<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
}
else
{
   document.write('<TABLE WIDTH="784" BORDER="0" CELLSPACING="0" CELLPADDING="0">');
}
// End of Script -->
</SCRIPT>
    </center>

  <p align="center">
    <br>
    <input type="checkbox" checked name="newinfo"><a href="farmhome-newinfo.asp">Show Farmhome New
Features
and Recent Changes</a>
    <br><br>
  <script LANGUAGE="JavaScript">
         if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion)
>= 4))
{
         var url="http://www.interglobalwaste.com/farmhome";
         var title="FarmHome.Com";
         document.write('<A HREF="javascript:window.ext');
         document.write('ernal.AddFavorite(url,title);" ');
         document.write('onMouseOver=" window.status=');
         document.write("'Add FarHome.Com To Your Favorites!'; return true ");
         document.write('"onMouseOut=" window.status=');
         document.write("' '; return true ");
         document.write('">Add FarmHome.Com To Your Favorites!</a>');
         }
         else {
              var msg = "Be Sure To Bookmark FarmHome.Com By Selecting:  Netscape Users:";
              if(navigator.appName == "Netscape") msg += "  CTRL-D; Opera Users:  CTRL-T";
                   document.write(msg);
         }
    </script></p>
<br>
    <tr>
    <td>&nbsp;</td>
    <TD><P><FONT FACE="Arial,Helvetica" SIZE="2"><B>Information on the security of your FarmHome service</B>
      <P>You are now within a secure <B>FarmHome</B> session using a 128 bit
      security key. The secure session is indicated by the padlock icon in the
      status bar at the bottom of the browser window. All data transmitted during
      your <B>FarmHome</B> session will be encrypted.
    <P></FONT></P></TD>
    </tr>

      <hr>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
          <TR>
            <TD colspan="5">
              <P align="center"><b><font face="Arial, Helvetica, sans-serif" size="3"><FONT color="#009966">InterGlobal
                Waste Management Inc.</FONT><BR>
              </font>
                <FONT color="#333399">820 Calle Plano Ave Camarillo CA 93012
                USA<BR>
                Tel.
                <FONT color="black">(805) 388-1588</FONT> Fax. <FONT color="black">(805)
                388-0667</FONT></FONT></b><FONT face="Arial, Helvetica, sans-serif"><B><FONT color="#333399">email:
              </FONT>
              <FONT color="#FF9900">
              <A href="mailto: farminfo@interglobalwaste.com">farminfo@interglobalwaste.com</A>
              </FONT>
              </B>
              </FONT>
                             <br> <br>
              </P>
            </TD>
          </TR>
          <TR align="center">
            <TD colspan="5" height="10">
              <DIV align="center"><FONT face="Arial, Helvetica, sans-serif" size="1"><B><FONT color="#009966"><A

href="/farmhome/farmhome3.asp">Homepage</A></FONT></B></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A

href="/farmhome/admin/company-info.htm">Company Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A

href="/farmhome/admin/privacy.htm">Privacy Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A

href="/farmhome/admin/copyright.htm">Copyright Information</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A

href="/farmhome/admin/terms.htm">Terms_Conditions</A></FONT>
<FONT color="#FF9900">|</FONT><FONT face="Arial, Helvetica, sans-serif" size="1" color="#009966"><A

href="/farmhome/farmhome-contactus.asp">Contact Us</A></FONT>
</DIV>
            </TD>
          </TR>
        </TABLE>
<center>
<p><b><font face="arial, geneva" size="-2">Copyright ? 2001 InterGlobal Waste
Management Inc. All Rights Reserved.
Any Problems? E-mail the <a href="mailto:webmaster@interglobalwaste.com">webmaster@interglobalwaste.com</a>.
<font face="Arial, Geneva" size="-2"></font></font></b><br>
<b><font face="arial, geneva" size="-2">If you are experiencing any viewing
problems, please download at least version 5.0 of either <a href="http://www.microsoft.com/ie/download/">Microsoft Explorer</a> or 6.0 <a

href="http://www.home.netscape.com">Netscape Navigator</a>.</font></b></p>
</center>

              </TABLE>
         </TD></TR>
    </TABLE>
    </center>

</TD>
</TR>
</TABLE>
</BODY>
</HTML>
ciao
Y
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310253
If the form "wasn't there yet" then the onload test that I mentioned earlier would not work - did you actually try that?

:o\

Ant
0
 

Author Comment

by:thocutt
ID: 6310259
Yes I see what you are talking about.

I got the message "not here yet" and then I got the message "here I am".

So what do I need to do to avoid that?
0
 

Author Comment

by:thocutt
ID: 6310278
OK I posted your code and it didn't give me any error messages!

I'm running a few tests.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6310279
?

Ant
0
 

Author Comment

by:thocutt
ID: 6310302
Thanks a bunch man!  That did the trick!
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6310596
thocutt :
hey no problem
just a few tips when you write code like that :
1) try to keep your code inside the <head>
when ever is possible so in your case the best think to do
would be have all of that cookie functions in a cookie.js
and include the file like <script language="javascript" src="/mydir/cookie.js"></script>

this way you can cache the file in the user machine
and then call the function in the onload event

2) do as much stuff as you can in the onload event of the window that will save you a lot of trouble like this where stuff is not defined yet expecially with serve side pages

3) like ant told you make sure all of your html is cool that will save you a lot of weird looking table in ns and mac

ciao
Y

a.marsh :

try this it might help you:

<html>
<head>
     <title></title>
    <script>
    checkIt=function(txt) {
        var oForm=document.myform
        if (oForm) {
            alert(txt+'\nI\'m here!')
            if (oForm.myinput) alert('I\'m the input');
            else alert('the input is comming soon!')
        } else alert(txt+'\nNot here yet')
    }
    checkIt('Function call in the head before the onload')
    </script>
</head>

<body onload="checkIt('Function call in the onload')">
<script>
checkIt('Function call before the <form>')
</script>
<form name="myform">
<script>
checkIt('Function call after the <form> and before the <input>')
</script>
<input type="text" name="myinput">
<script>
checkIt('Function call after the <input>')
</script>
</form>
</body>
</html>

ciao
Y

I guess you are
0
 

Author Comment

by:thocutt
ID: 6313307
Yeah, you guys are right.  There are definitely some fundamentals that I need to go back and get a better handle on.  Thank you so much for your help.  I really appreciate it and learned a lot!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now