[Javascript] referring to a form in a div

Peter Brunone peter at brunone.com
Wed May 2 09:27:50 CDT 2001


    Let me rephrase that.

    I tried it, and it didn't work.  The same error just keeps popping up,
that document.layers.queryInputDiv.selectForm has no properties.  Here's the
entire content of the DIV (tried it with and without the NAME attribute, but
with no success):

<DIV ID="queryInputDiv" NAME="queryInputDiv" CLASS="queryInput">
<FORM NAME="selectForm">
<TABLE WIDTH="150" BGCOLOR="#63ADEF" BORDER=1 BORDERCOLOR="#000000"
CELLPADDING=3 CELLSPACING=2>
<TR>
 <TD COLSPAN=2 ALIGN="CENTER" NOWRAP>
  <SELECT NAME="criterion">
   <OPTION VALUE="blank">Location:</OPTION>
   <OPTION VALUE="Region">--Region</OPTION>
   <OPTION VALUE="District">--District</OPTION>
   <OPTION VALUE="Store">--Store</OPTION>
   <OPTION VALUE="blank">Merchandise:</OPTION>
   <OPTION VALUE="Division">--Division</OPTION>
   <OPTION VALUE="Entity">--Entity</OPTION>
  </SELECT> &nbsp;
 <INPUT NAME="queryParam" SIZE=4 MAXLENGTH=4></TD>
</TR>
<TR>
 <TD ALIGN="CENTER"><B><A HREF="javascript:getSpecific()"
 STYLE="text-decoration:none;"
 onMouseOver="window.status='Go';return true;"
 onMouseOut="window.status='';return true;">OK</A></B></TD>
 <TD ALIGN="CENTER"><B><A HREF="javascript:hideObject(queryInput)"
STYLE="color:#FF0000;text-decoration:none;">Cancel</A></B></TD>
</TR>
</TABLE>
</FORM>
</DIV>

    The JavaScript code is in a separate script block, and reads like this:

function getSpecific() {
 if(ie4) {
  alert(document.selectForm.queryParam.value);
  }
 else {
  alert(document.layers.queryInputDiv.selectForm.queryParam.value);
  }
 }

    And the style for the DIV is

.queryInput {
 position:absolute;
 visibility:hide;
 visibility:hidden;
 left:40%;
 top:20%;
 }

    Is there something blatant that I'm missing?

----- Original Message -----
From: "Chris Basken" <chriz at basken.com>
To: <javascript at LaTech.edu>
Sent: Wednesday, May 02, 2001 8:51 AM
Subject: RE: [Javascript] referring to a form in a div


> >     Okay, so the IE one was a no-brainer ;-)
> >
> >     What if you're not using layers?  Last time I checked (just
> > now), <DIV>
> > tags weren't part of the layers collection.
>
> in NS4, a <layer> and a <div> are both the same thing if you've given the
> <div> absolute positioning via CSS (this is also true for <span> and
> possibly others).  so if the form's inside a non-absolute DIV, you just
call
> it as part of the document object (document.forms).  this is also true for
> forms outside any layers.
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list