...

View Full Version : Send data to opener document



guvenck
01-31-2007, 04:17 PM
I'll make it simple.
I have a popup and a form in it. The form is being generated with PHP.




<form name="PopupForm">
<input type="text" name="gk1154567" value="gk1154567" readonly>
<input type="button" value="Send" onClick="javascript:SendToOpener('gk1154567');">
</form>




When clicked on Send, I want the gk1154567 (which is both the name and the value of the text field) to be sent to a field in a form in the opener document.




<form name="OpenerForm">
<input type="text" name="openerformfield">
<input type="submit" value="Submit">
</form>




This is the JS function I wrote:




function SendToOpener(fieldname) {
opener.document.OpenerForm.openerformfield.value = document.PopupForm.fieldname.value;
}



When I load the page and click the button, I get this error in JavaScript Console:

Error: localForm.fieldname has no properties

Any ideas what I am doing wrong?

guvenck
01-31-2007, 04:40 PM
Changed the function to:



function SendToOpener(fieldname) {
if (window.opener && !window.opener.closed) {
window.opener.document.OpenerForm.openerformfield.value = fieldname;
window.close();
}
}


and it works now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum