Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do i refresh parent page and set some values based on child page selection using java script on click of button in child page ?

I have one parent page which contains one text box and one button. On click of button it will open another page(child page) with textbox and submit button.On click of submit in child page, the value selected in textbox of child page should come in parent page textbox and child page should be closed.

please explain how can i do this using javascript. ???
Posted
Updated 5-Feb-15 22:57pm
v4

Assuming you're using window.showModalDialog to open the window (since window.open does not allow for return values), you'd just set the returnValue property of the modal and then set it to a variable in the opener.

Opener window:

JavaScript
var returnedValue = window.showModalDialog(url);

Modal window:

JavaScript
window.returnValue = 'foo';
window.close();


Thanks go to jbabey from SO for this.

If this helps please take time to accept the solution. And next time take time to search for the answer before asking. Thank you.
 
Share this answer
 
v2
Comments
Am Gayathri 6-Feb-15 4:55am    
Thanks for your replay.
Am using window.open only. Below code can solve this.

function setparent(value)
{
var a= window.opener.document;
a.getElementById('p').innerHTML = document.getElementById('p').innerHTML;

window.close();
}
To set the value of parent, we can use below code.

C#
function setparent(value)
{
var a= window.opener.document;
a.getElementById('p').innerHTML = document.getElementById('p').innerHTML;

window.close();
}


This code will set the paragraph inner html of parent page.(Paragraph id is p)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900