Update parent form objects from child form data 
Author Message
 Update parent form objects from child form data

I have a problem updating the value of text boxes on a parent form,
using a value selected from a list on a child form.

There are a large number of text boxes on the parent form and any one
of them could be the source for an update. Hence I identify the text
box by storing its name in a hidden input on the parent form and then
I store its name on the child form - again in a hidden input using the
onLoad() function.

How do I specify the name of the ParentForm input box in the
window.opener statement when I want to update its value ?

function onLoad()
{    
  document.ChildForm.UpdatePage.value = "";

  document.ChildForm.hQryName.value =
window.opener.document.ParentForm.hQryName.value;
  ......
  ......

Quote:
}

function SaveData()
{
  var object_name = document.ChildForm.hObjName.value;

  if (window.opener && !window.opener.closed)
  {    
    window.opener.document.ParentForm.???_object_name_???.value =
newvalue;
  }  
  window.close();

Quote:
}  

<INPUT TYPE="button" ALIGN="LEFT" VALUE="Save" onClick="SaveData()"
 onMouseOver="msover()" onMouseOut="msout()" id=nmEdProdSave
name=nmEdProdSave>

I have also tried building the window.opener statement via server side
code but all it does is write the line out to the page.

<script language=javascript>
<!--
<%Sub aspSaveData()%>

    <%
    newvalue = Request.Form ("nmDesc")    
    objectname = Request.Form ("hobjName")
    Response.write("window.opener.document.ParentForm." + objectname +
".value  = " + newvalue + ";")
    %>

<%end sub%>
//-->
</script>

Can anyone help ?
Thanks in advance.



Mon, 28 Jun 2004 12:53:35 GMT  
 Update parent form objects from child form data

Quote:

> I have a problem updating the value of text boxes on a parent form,
> using a value selected from a list on a child form.

> There are a large number of text boxes on the parent form and any one
> of them could be the source for an update. Hence I identify the text
> box by storing its name in a hidden input on the parent form and then
> I store its name on the child form - again in a hidden input using the
> onLoad() function.

> How do I specify the name of the ParentForm input box in the
> window.opener statement when I want to update its value ?

> function onLoad()
> {    
>   document.ChildForm.UpdatePage.value = "";

>   document.ChildForm.hQryName.value =
> window.opener.document.ParentForm.hQryName.value;
>   ......
>   ......
> }

> function SaveData()
> {
>   var object_name = document.ChildForm.hObjName.value;

>   if (window.opener && !window.opener.closed)
>   {    
>     window.opener.document.ParentForm.???_object_name_???.value =
> newvalue;
>   }  
>  window.close();
> }  

> <INPUT TYPE="button" ALIGN="LEFT" VALUE="Save" onClick="SaveData()"
>  onMouseOver="msover()" onMouseOut="msout()" id=nmEdProdSave
> name=nmEdProdSave>

> I have also tried building the window.opener statement via server side
> code but all it does is write the line out to the page.

> <script language=javascript>
> <!--
> <%Sub aspSaveData()%>

>     <%
>     newvalue = Request.Form ("nmDesc")    
>     objectname = Request.Form ("hobjName")
>     Response.write("window.opener.document.ParentForm." + objectname +
> ".value  = " + newvalue + ";")
>     %>

> <%end sub%>
> //-->
> </script>

> Can anyone help ?
> Thanks in advance.

I found the answer whilst browsing through another user group.

The solution is to use eval to create the full window.opener statement, as it
allows you to include variables and strings to create a Jscript statement.

function SaveData()
 {
   var object_name = document.ChildForm.hObjName.value;

   if (window.opener && !window.opener.closed)
   {    
     eval("window.opener.document.ContentForm." + object_name + ".value
     = "+ "'" + newvalue + "'");
   }  
  window.close();
 }



Tue, 29 Jun 2004 12:18:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. submit form in child window to parent - IE4 problem

2. Updating parent window and closing child window

3. Updating parent window and closing child window

4. Updating a parent window and closing the child

5. Multiple forms in a parent form

6. Passing data from child to parent (Please help)

7. Accessing the form object a Parent window

8. Linking Form Objects in HTML to other Form Objects using VBScript

9. Passing Data from FORM to FORM

10. Moving input data from Form to Form

11. Grabbing Form data without using the Request.Form() Method

12. get access to a parent object via its child

 

 
Powered by phpBB® Forum Software