PDA

View Full Version : opener.location.reload.grrrr



moloko_man
11-21-2005, 05:12 PM
Not sure if my problem is in my php or my javascript, but here goes.

I have page 1 that has my form and below that fields that I populate from a mysql DB. The user can click on "add employee". here page 2 pops open with a list of employees, the user checks the employee they want to add, then when they click add the window closes and page 1 should refresh and show the new user below the form. Here is where my problem is... after page 2 closes, page 1 goes blank and sits there reloading until I get a network error. After that error I can view the page with the new employee has been added.
Anyone know whats going on?

On page 1 i'm using window.open

My reload code on pg. 2 is:

<script language="JavaScript" type="text/javascript">
<!--
opener.location.reload(true);
self.close();
// -->
</script>

jscheuer1
11-21-2005, 07:29 PM
Well, your scriptlet, as is, would execute as soon as the page it is on parses it. You probably have it, or would want to have it, as a function activated onclick or on some event on the page. Second, reloading a page will generally get you that page as it is written, without any updated information. If all you want to do is update information on the opener, simply access or create an element on it, adding the new information:


<script type="text/javascript">
function updateOpener(){
var box=opener.document.createElement('input')
box.type='text'
box.value='new employee'
opener.document.body.appendChild(box)
self.close()
}
</script>


<input type="button" value="Update" onclick="updateOpener();">