Pop Up Window

Contributor
14Nov2005,12:47   #1
prashantSum's Avatar
hi,
I don't know exactly where to post this exactly, please forgive if I should not have posted it here.

I have a problem, I have to open a popup window in which I have to show some check boxes, now when the user selects some check boxes I want get these values back to the window from where the popup window has been opened.

how can I do this.. I am using J2EE on the server side, does request has to sent back to server,.. or can I do it in some other way...

please help me...
Go4Expert Founder
14Nov2005,14:56   #2
shabbir's Avatar
This can be done using the plain JavaScript and does not need to be passed to the server. You can just write a JS function to reflect the changes from the child to the parent in the following manner

Code:
<script language="javascript">
function reflect()
{
	parent.opener.window.document.<FormName>.<FieldName>.value = document.<ChildFormName>.<Field>.value;
	return true;
}
</script>
Team Leader
14Nov2005,15:37   #3
pradeep's Avatar
To pass on some values to the "opener" window from the "opened" window, you have to use the window.opener object.

Example:
Code:
//in the original window
  var bValueFromPopup = false;
  document.form.myForm.button.onClick=function()
  {
     window.open("pop.htm","testt");
  }
  
  //this opens the file pop.htm in a new pop-up window.
  
  //in pop.htm, if you want to change/pass a value to the orginal window
  document.form.newForm.myButton.onClick=function()
  {
     window.opener.bValueFronPopup=true;
  }
  
  //this will change the value of the variable bValueFronPopup in the main window.
You got the logic, hope now u can work on your problem.In case of any prob, dont worry, I am just a mouse click away ;-)

----------------------------------
Computers are like airconditioners, if you open WINDOZE they don't function!

http://spradeep.blogspot.com
Contributor
14Nov2005,15:50   #4
prashantSum's Avatar
thx for the replies,

I got that it....

one more thing is, I have some check boxes in the popup window, now when select some check boxes in the that window and close that window and again open it check boxes which I have selected previously are not persisted (they are again coming to non select state)..

how can we persist those selections until the parent form is submmited
Team Leader
14Nov2005,15:53   #5
pradeep's Avatar
Yes, you can do that, all you have to do is read the data from the main page,using the same logic.
Contributor
14Nov2005,19:17   #6
prashantSum's Avatar
thx for the replies,

parent.opener.window.document.<FormName>.<FieldNam e>.value = document.<ChildFormName>.<Field>.value;

now the above code is working fine when I opened a window with window.open

but...
it's not working when I open a MODAL window....

with window.showModalDialog(....)

does it not work with the modal windows or do I need to change some code
Team Leader
15Nov2005,10:46   #7
pradeep's Avatar
parent.opener wont work with showModalDialog, 'cause its not a pop-up window, its a dialog.You can pass & retrive values in ModalDialog too, for more help on that check this link http://www.webreference.com/js/column90/3.html
Contributor
15Nov2005,15:31   #8
prashantSum's Avatar
thx pradeep,

I got it.