1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Pop Up Window

Discussion in 'JavaScript and AJAX' started by prashantSum, Nov 14, 2005.

  1. prashantSum

    prashantSum New Member

    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...
  2. shabbir

    shabbir Administrator Staff Member

    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

    <script language="javascript">
    function reflect()
    	parent.opener.window.document.<FormName>.<FieldName>.value = document.<ChildFormName>.<Field>.value;
    	return true;
  3. pradeep

    pradeep Team Leader

    To pass on some values to the "opener" window from the "opened" window, you have to use the window.opener object.

    //in the original window
      var bValueFromPopup = false;
      //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
      //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!

  4. prashantSum

    prashantSum New Member

    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
  5. pradeep

    pradeep Team Leader

    Yes, you can do that, all you have to do is read the data from the main page,using the same logic.
  6. prashantSum

    prashantSum New Member

    thx for the replies,

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

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

    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
  7. pradeep

    pradeep Team Leader

    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
  8. prashantSum

    prashantSum New Member

    thx pradeep,

    I got it.

Share This Page