Passing string from JavaScript popup to parent window
I have a JavaScript function that looks like this. I need help passing these values from the JavaScript of the popup to the parent window. I know what I have to use
window.opener.document.getelementbyD("ID Of TextBox");
in my aspx child page, but textbox
is inside another custom control. How to do it?
function(PersonName, EmailID){
//assign these values to text boxes of a parent window
//the text boxes of parent window are inside of control
}
Regards
-Vishu
-2
a source to share
1 answer
You can write two simple JS functions. One (setValues) in your "parent" window, which is called on popup. And one in your popup menu (setValuesToParent), collecting values and calling a function in your parent window. Please remember that this example is written in plain JavaScript and does not use any asp.net stuff.
// in your pop up
function setValuesToParent() {
var PersonName= document.getElementById('PersonNameInPopUp').value;
var EmailID = document.getElementById('EmailIDInPopUp').value;
window.opener.setValues(PersonName, EmailID); // this is the important line
}
// in your parent window
function setValues(PersonName, EmailID) {
document.getElementById('PersonName').value = PersonName;
document.getElementById('EmailID').value = EmailID;
}
0
a source to share