|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hi there I was wondering if it's possible when the popup window loses, the parent window refreshes the form but leaves the entered data previously intact?? I'm not too sure on how to do it. could anyone give some tips or ideas? thanks =)
thanks in advance ![]() |
|
#2
|
|||
|
|||
|
i think you will need to use cookies for that
|
|
#3
|
||||
|
||||
|
if you are using asp or some other server side technology, you could just have the form submitted to the same page, and populate the fields by picking up the request.form elements
or, perhaps, on the pop up window, you could do an onLoad() and an onUnLoad() function for the body something like: var o = window.opener; var f = o.document.forms[0]; var arFields = new Array() function retrieveFields() { for ( var i = 0; i < f.elements.length; i++ ) { arFields[i] = f.elements[i].value; } } function refreshPopulate( ) { o.location.reload() for ( var i = 0; i < arFields.length; i++ ) { f.elements[i].value = arFields[i] } } you'll have to modify it to handle non-text input fields |
|
#4
|
|||
|
|||
|
problem oriented implementation
I have used a part of this code in my solution to refresh some option boxes generated from database values.
I have a reload button in a form and data in another form. When I click the reload button a new window appeares and saves all the text and selected options from one options box. After that it refreshes the parent form and closes itself after 1 second. On closing it restores the values back to the form. I changed the location of the reload request. So that the page is properly loaded before we access any functions and properties. Otherwise you get an error in IE about nonexisting properties and functions. <script language="JavaScript"> var o = window.opener; var f = o.document.forms[0]; var arFields = new Array() var selectedText=new Array(); var selectedValues=new Array(); function retrieveFields() { for ( var i = 0; i < f.elements.length; i++ ) { switch(f.elements[i].type){ case "text" : arFields[i] = f.elements[i].value; break; case "textarea": arFields[i] = f.elements[i].value; case "select-multiple" : if(f.elements[i].name=="list2"){ for(j=0;j<f.elements[i].length;j++){ selectedText[j]=f.elements[i].options[j].text; selectedValues[j]=f.elements[i].options[j].value; } } break; case "hidden" : arFields[i] = f.elements[i].value; break; } } var o=window.opener; o.location.reload(); } function refreshPopulate( ) { var f = o.document.forms[0]; //alert("after reload call " + o.name); for ( var i = 0; i < arFields.length; i++ ) { switch(f.elements[i].type){ case "text" : f.elements[i].value = arFields[i]; break; case "textarea": f.elements[i].value = arFields[i]; case "select-multiple" : //just do nohting, use AddOptionToList of main page break; case "select-single": break; case "hidden": f.elements[i].value = arFields[i]; break; } } //add options back to the list for(i=0;i<selectedText.length;i++){ o.AddOptionToList(f.list2,selectedText[i],selectedValues[i]); } } </script> <body onLoad="retrieveFields();setTimeout(window.close, 1000)" onUnload="refreshPopulate()"> <h1>Page is reloading</h1> <p>just wait a second or <a href="javascript:window.close()">close this page</a> </p> </body> </html> |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > refreshing the parent window when a popup closes using javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|