Click to See Complete Forum and Search --> : Providing heading to table in parent form from child form


anshul9189
10-23-2003, 12:24 AM
I have a parent form which has a "Add New" button. When Ever the clicks on this button a new window opens which contains some form fields. On clicking submit those fields go back to the main form as 1 row. User can add any number of rows in this manner.
Here is the code for parent form:

<html>
<head>
<script language="JavaScript">
function submitForm()
{
form1.action="capitalRequestSubmit.jsp";
form1.submit();
}
</script>
</head>
<body>
<form name='form1' >


<DIV id="mydiv"> </DIV>


<input type="button" value="Add New" onclick='winnew=window.open("child.jsp","jsp","width=600,height=500,scrollbar=yes"); winnew.focus'>
<input type="button" value="Submit" onClick='submitForm();'>
</form>
</body>
</html>

And here is the code for Child form

<html>
<head>
<title>Child</title>
<head>
<script language="JavaScript">


function addTextboxIncome()
{
var val0 = document.frmMain.name.value;
var val1 = document.frmMain.specification.value;

self.opener.document.getElementById("mydiv").innerHTML += '<TABLE width=143% class=tableMain border=2><TR><TD><textarea name="name" >'+val0+'</textarea></TD><TD> <textarea name="specification" >'+val0+'</textarea> </TD></TR></TABLE>';

window.close();
}
</script>
</head>

<body>
<FORM name="frmMain" >
<TABLE border="2" align=center>
<TR>
<TH>Name of Item</TH>
<TH>Specification</TH>
</TR>
</TABLE>

<a href="#" tabindex="2101" onclick="addTextboxIncome();"><font size=2><b>Add</b></font></a>
</form>
</body>
</html>

(There r many fields but I am showing only 2 to avoid making it messy)
It works perfectly fine till here. The problem in dispalying the headings in the parent page above all the rows. If I do this in the child form.

self.opener.document.getElementById("mydiv").innerHTML += '<TABLE border=2><TR><TD>NAME</TD><TD>SPECIFICATION</TD></TR><TR><TD><textarea name="name" >'+val0+'</textarea></TD><TD> <textarea name="specification" >'+val0+'</textarea> </TD></TR></TABLE>';

the problem that comes is that the headings are displayed over every row in the parent form but I want it to display only once. If I put the code for heading in a seperate table in the parent form that displays it as a seperate row, so alignment for heading and data values do not match. I want the data values to display exactly under the heading (as part of single table)

Thanks