• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using JavaScript how to pass parent form value to child

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I pass a parent form value to a child form? I have the following code.
var newWin = window.open('getInfo.jsp','newWindow','height=200,width=500,location=no,toolbar=no,scrollbars=no,resizable=no,left=0,top=0');
newWin.document.childForm.personName.value = document.parentForm.personName.value;
The child window opens but the parent window has a JavaScript error: 'document.childForm.personName' is null or not an object. The parent value is not passed to the child.
What do you suggest?
Thanks for your time and help!
Tiffany
 
Tiffany Collins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it.
In getinfo.jsp body onload tag:
document.childForm.personName.value=window.opener.document.parentForm.personaName.value
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will tell you the reason why you were getting the error and why your solution fixed it.
The parent would call it right after it called the window.open method.
The problem is that it happens so quick that the form and its elements in the child were never written to the page in time.
The onload event waits until that page is fully loaded then it firs the code.
Hope that gives you some insight to what happens.
Eric
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic