View Full Version : cannot pass parameters back to the main window from a popup
Hi there, I have a problem trying to pass parameters back from a popup to the main window(opener), I trying to set some values (to some hidden fields on the main window) but with no success. here a copy of the popup method that tries to set the value to the hidden fields in the opener. please note that the first field "opener.theField.value" is a reference to a regular field in the form and does not have any problem, but all the other ones are fields directly from the form and they are hidden, there's where I have the prob.. thanks a lot
var errorMessage;
var tempFlag
//*----------------------------------------------------------*
//* returns the values to the calling object
//*----------------------------------------------------------*
function putLabel(form)
{
if (opener && !opener.closed)
{
if(!validateFields())
{
opener.theField.value=form.daily.value;
opener.document.sunTax.value = form.tax.value;
alert("aki");
opener.document.sunHotelName.value = form.hotel.value;
opener.document.sunCreditCharge.value = form.charge.value;
opener.document.sunReason.value = form.reason.value;
opener.document.sunReceipts.value = form.receipts.value;
opener.document.reportForm.sun9.value=form.hotel.value;
window.close();
}
else
{
alert(errorMessage);
errorMessage = "";
}
}
}
:confused:
renderboy
01-29-2004, 09:39 PM
I am not sure but wouldnt you use the parent property of the window you are writing back to since the popup would be a child of that page - for example
parent.IS_Attr_CallBack.value = 'Y';
If I am not correct please correct me
Renderboy
glenngv
01-30-2004, 05:05 AM
One of the proper ways of absolutely referencing fields is:
window.document.formNameHere.fieldNameHere
(Other form of referencing is by using the bracket notation)
So in your case, it should be:
opener.document.formNameHere.sunTax.value=form.tax.value;
...
Just specify the appropriate form name of the opener window.
I don't know why "opener.theField.value" worked. Is theField a variable that refers to a field or the name of a field itself?
renderboy, the parent property is only used in frames/iframes.
Thanks, I have no excuses, .......... btw, is there anyway to create a kind of "popup" using javascript, but not the normal popup(window) but something fancy, like a frame that opens an closes in the same main window, I have seen that but don't remember where. this kind of frame should pass parameters back to the main window......if know of something pls. let me know...
and again thanks for the answer, ................how st..... I was...::D
glenngv
01-30-2004, 07:47 AM
http://www.codingforums.com/showthread.php?s=&threadid=17228
that's really cool, but how about passing data back to the main window. I'm thinking on using layers if that is possible....I could(maybe), set the visibility attribute to be visible or hidden, not sure yet if that is going to work. problem I have w/the frame is that I dont know if I have a reference to the main window, but still that's a very cool JS:thumbsup:
something like?
http://www.amaltea.ro/carte.php?id=86
and click on one of the 3 underlined links below
glenngv
01-30-2004, 08:58 AM
Originally posted by vihv
that's really cool, but how about passing data back to the main window. I'm thinking on using layers if that is possible....I could(maybe), set the visibility attribute to be visible or hidden, not sure yet if that is going to work. problem I have w/the frame is that I dont know if I have a reference to the main window, but still that's a very cool JS:thumbsup:
Since the "popup" is contained in the <iframe>, you can access data from the parent to the iframe (and vice versa) as you would normally do in normal frames.
To access data from iframe to the main window, you just specify parent as the window object as renderboy suggested earlier.
To acces something on the main page
If iframes
parent.thatfunction()
parent.document.... the rest of ref.
If popup
window.opener.thatfunction()
window.opener.document... the rest of ref.
Hey guys thanks a lot, dont you sleep, do you get any money for helping us??......
liorean
01-30-2004, 11:17 AM
No we don't sleep (or at least, we don't sleep enough). And we're not getting paid for helping you. We're just devoted to the community.
...Furthermore... I guess we would not have been so devoted if payed. Work is boring, free help is fun...:D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.