We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

post value from child to parent

topdeveloper1
on
Medium Priority
285 Views
Last Modified: 2012-06-22
Hi All,
If any one can help me to create a javascript for:

I have a parent window and a child window.
when i put some value in child window(having form action=" parent file")
and
click on submit button then
pop-up window(child window) should closed
and
the posted values should be in parent form. so that when i refresh parent page values remained there.
Comment
Watch Question

On you parent page
<form name="received" method="post" action="#"></form>

On your child page
<script>
function PassToParent(obj) {
      opener.document.getElementById('received').innerHTML = obj;
      opener.document.getElementById('received').submit();
}
</script>

<form name="child">
<input type="textbox" name="ABC" value="ABC">
<input type="button" value="submit" onClick="PassToParent(this.form.innerHTML);self.close();">
</form>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Browsers are not required to save the state (form information - or anything set in JavaScript) pages when asking for a refresh.
A nice feature of better browsers is, when a page was loaded by a "post" method, when asking for "refresh" the browser will ask you if to resubmit the "post" data.
Plus if the page was created with a "get" with parameters in the URL query, any refresh will include the state.
No objection here.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.