copyright © CSSPG, lud October 18 2000


 for practical use of CSS

Tips

this document is located at...
<URI:http://css.nu/pointers/tip-2.html>

* Forms and <LAYER> *

  Mark Bunkowske wrote:

  > When working with Netscape's Layers I have found that if you include a
  > form
  > like the following:
  > <FORM><LAYER>...</LAYER><LAYER>...</LAYER></FORM>
  > the form elements do not show up..
  > However if there is a form tag within each layer tag the form elements
  > show up
  > but when it comes to actually submitting the form(s) ... well lets just
  > say the code involved wont be too pretty (at least from what I can see
  > (i havent tried it yet))
  > and VERY slow

 

Shelley Powers responded:

The problem with forms and layers (including ones where DIV is used instead of the LAYER element) is that any element included within a layer becomes an element of the layer's document property instead of the main web page document property.

I imagine you are using forms and layers to create a multiple layered form, but want all the data sent at once. If this is the case, I have a workaround which you might find acceptable.

You know that you can create another hidden form that contains all of the fields you want to submit. Then, with each of the "displayed" form fields, capture the onchange event and call a function such as "changed('fieldname',this.value)". The changed function could be similar to:

  function changed(field, thevalue) {
   document.submitted.document.theform.elements[field].value = thevalue;
  }

 

where the form named "theform" is the hidden form that will be submitted. You must use the "document" property of the DIV block in order to access the form. Then when the button that processes the form is pressed, call the submit() method for the hidden form. This is fast, and relatively clutter free in coding, pretty much just requiring the onchange event handler code.

This will also work with IE 4.0, except use:

  document.submitted.elements[field].value = thevalue;

 

as to IE 4.0, the forms of a page are collections that belong to the page document object, not the positioned blocks.

You can position the forms directly, without a layer or DIV block, with Navigator 4.0, but I noticed that the form elements do not seem to be accessible via code. Still playing around with this a bit. Positioning forms directly does not work with IE 4.0.

To make things even more interesting, IE 4.0 doesn't require that input elements be included within a form, but Navigator does.

Hopefully this will provide starting point for other input.

Shelley

  --
  =============================================================
  Shelley Powers       YASD
  shelleyp@yasd.com    http://www.yasd.com
                       http://www.dynamicearth.com


CSS Pointers Navigation
Index · Browser Bugs · Books · Tools · DHTML · XSL & DSSSL
Main Site Navigation
Index · Articles · Examples · Experiments · FAQ · Markup · Styles · Who is?
CSSPG ~ Sue ~ Roland
Validate markup Check CSS