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