I have a web page, say Page1.aspx containing 2 controls - a textbox and a button.
i click the button to open another page say Page2.aspx, using window.showModalDialog containing another textbox and a button.
i type something on this textbox and click the button on Page2.aspx.
what i need is that Page2.aspx should close and whatever was typed on the it's textbox should get copied to the textbox on Page1.aspx
Loading
Pankaj GPosted Jan 10, 2006, 6:49 AM
I assume you have written code in Parent window like
var objValue = window.showModalDialog ("page2.aspx")
Note: You can get the values in objValue from the Dialog window using window.returnValue.
In the page2.aspx on clcik of button call Javascript function to assign the textbox value to window.returnValue.
like:
function UpdateParent(){
window.returnvalue = "HERE I BE"
window.close ;
}
Umamaheswari GopalPosted Jan 9, 2006, 7:17 AM
Please do refer the following,
Let’s say the Parent window named as TestParentForm and the text box we wanted to pass the value from the child window is named as “txtParentName”. We just the call the parent widow as opener. Form the child window (TestChildForm) we can access the parent form’s object as follows,
opener.document.TestParentForm.txtParentName
The value for this object can be assigned like this
opener.document.TestParentForm.txtParentName.value="ABC";
We will try to make it interactive so we will assign this to a value entered by the user. Then we will use one input box in child window and name it as txtChildName. So we can pass the value of the input box of child window to the parent window input box by this line.
opener.document.TestParentForm. txtParentName.value = document.TestChildForm.txtChildName.value;
We will keep this line inside a function and call this function on click of a button. Inside the function after executing the above line we will add the code to close the child window. Like this,
opener.document.TestParentForm. txtParentName.value = document.TestChildForm.txtChildName.value;
self.close();