Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1385 How can I create a single form that submits fields that are positioned in different Netscape Navigator layers?

You are here: irt.org | FAQ | DHTML | Q1385 [ previous next ]

Simply put: you can't. Each layer is a separate document, and therefore any form fields have to within a separate form for each layer.

A workaround, would be to have a hidden form field in the main page, and then pull in the results form all the sub-forms into this main form when the onSubmit event is triggered:

<html>

<head>

<script language="JavaScript"><!--
function populate() {
    if (document.layers) {
        document.mainform.text1.value = document.layer1.document.form1.text1.value;
        document.mainform.text2.value = document.layer2.document.form2.text2.value;
        document.mainform.text3.value = document.layer3.document.form3.text3.value;
        document.mainform.text4.value = document.layer4.document.form4.text4.value;
    }
    else {
        document.mainform.text1.value = document.form1.text1.value;
        document.mainform.text2.value = document.form2.text2.value;
        document.mainform.text3.value = document.form3.text3.value;
        document.mainform.text4.value = document.form4.text4.value;
    }
}
//--></script>

</head>

<body>

<span id="layer1" style="position:relative;">
<form name="form1">
<input type="text" name="text1">
</form>
</span>

<span id="layer2" style="position:relative;">
<form name="form2">
<input type="text" name="text2">
</form>
</span>

<span id="layer3" style="position:relative;">
<form name="form3">
<input type="text" name="text3">
</form>
</span>

<span id="layer4" style="position:relative;">
<form name="form4">
<input type="text" name="text4">
</form>
</span>

<form name="mainform" onSubmit="populate()">
<input type="hidden" name="text1">
<input type="hidden" name="text2">
<input type="hidden" name="text3">
<input type="hidden" name="text4">
<input type="submit" value="Submit">
</form>

</body>

</html>

©2018 Martin Webb