faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 15 people (60%) answered Yes
Recently 5 of 6 people (83%) answered Yes

Entry

Can a FORM span several layers? If so how to add new Form elements on a new layer?

Jun 12th, 2001 04:06
Colin Fraser, Angelo Schneider,


You can try but it will not work.
To add a little more to that
Try to look at it this way, a layer can act independently of the page, 
but a form cannot, and that is probably the best explanation for the 
moment without reams of paper to prove it. What you may want to try 
however may be this 
Add one form per layer then a hidden form 
<SCRIPT LANGUAGE="JavaScript"><!--
 function copyforms() {
    document.form3.text1.value = document.div1.form1.text1.value;
    document.form3.text2.value = document.div2.form2.text2.value;
    document.form3.submit();
    return false;
 }
 //--></SCRIPT>
<div id="div1">
 <FORM NAME="form1" onSubmit="return copyforms()">
 Name: <INPUT TYPE="text" NAME="text1">
 <P>
<INPUT TYPE="BUTTON" VALUE="Submit" onClick="copyforms()">
 </FORM>
</div>
<div id="div2">
 <FORM NAME="form2" onSubmit="return copyforms()">
 Address: <INPUT TYPE="text" NAME="text2">
 <P><INPUT TYPE="BUTTON" VALUE="Submit" onClick="copyforms()">
 </FORM>
</div>
 <FORM NAME="form3">
 <INPUT TYPE="HIDDEN" NAME="text1">
 <INPUT TYPE="HIDDEN" NAME="text2">
 </FORM>
In this way you can have your forms and eat the data too. Set whatever 
options you want for the DIVs and it should work adequately for your 
purposes. As long as the hidden text boxes are aligned to the 
appropriate visible forms then it should work for what you need.