I want to be able to open a window with a variable. For example, I will use domain.com?reference=1234- This link will open a pop up window as follows:

<a href="javascript:popUp('http://www.domain.co.uk/staff/tpr/update_action_log.php?action_reference=<?php echo $row2['action_reference']; ?>')" title="Click Here edit this entry"><?php echo $row2['action_reference']; ?></a>

When I open this window, it is always showing data put in last, it isnt refreshed.

I wanted to open this pop up window, enter data and then click submit and make the data enter the database and then refresh the parent window.

Every time I have done this, either the parent or the pop (or both) is showing old data.


It seems so basic. I have used pop ups before and not had this problem


It all depends on how your javascript function popUp is written.

Post the code and I'll have a look at it.


OK, excellent. So, this is what I've got.

I am building an online control panel for a business. This particular function was for updating reports. The main page shows the report detail and below this it displays all of the actions taken again that report. Each time a use logs an action it is shown in this list. This is a bit irrelevant.

Anyway - I wanted to allow the user to select an action entry and then be able to edit it. As far as entering data into a database, retrieving it, and editing or deleting it is concerned, I do this all day everyday so I have a good knowledge on this. As far as JavaScript is concerned, my knowledge is slightly lacking.

In the main page that presents the user with the report and action logs, I have this:

<script>function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=805,height=575,left = 470,top = 200');");
// End -->

The above opens the pop up window absolutely fine. One thing that did concern me was for reasons unknown to me, the old data can appear. For example, if I update the details field in the pop up window and clicked submit, it would update the database and close the window but on clicking the pop up window again, it shows me what was previously in the 'details' box. If I hit F5 it does refresh the info to what is actually contained within the field.

Now finding a new problem as I mentioned above, I decided to try fixing this with a reload script. Unfortunately this was again in JS which I am not totally familiar with. I put the following in the top of the page:

<script language=" JavaScript" ><!-- 
function MyReload() 

and then placed this in the header

<Body onLoad="MyReload()" >

This solved absolutely nothing and didnt function so I carried on looking in to the original problem.

The only way around this that I have found to far is to allow the user to submit the form either to itself or to another page and then create a link to close the window and refresh the parent using the following

<a href="javascript:window.close();
if (window.opener &amp;&amp; !window.opener.closed) {
} ;">here</a>.

Whilst this does achieve what I want, I would much rather it all happened when the form was submitted because if the user doesnt click the close button, the parent window isnt refreshed.

I hope that info helps. Any ideas on this?


Looks like you are doing everything right so I'm not too sure what might be inhibiting the reload. It's unlikely to be server/proxy/local cacheing if F5 is reliable.

Try this first - my little popup opener.

var $W = null;//global or outer member
function queryWin(w){ return !(w===null || w.closed || typeof w === 'undefined'); }
function openWin(url){
	ff = [];//features list - adjust as necessary
	if(queryWin($W)) { $W.location.href=url; }
	else { $W = window.open(url, 'W', ff.join(',')); }
	if($W.focus) { $W.focus(); }

I'm not sure it will have any effect but give it a go.

If it doesn't work, then we'll try something completely different ......


Hey, Airshow,

Thanks for the reply. I am working on it at the moment so that is a great help.

Having said that, where am I putting this code??!?!? Sorry, I work on databases mainly. JS means near to nothing to me :-( lol

Comment out your existing function popUp(URL) { ...... } and paste my code in immediately below it.

Use /* ....... */ to comment out the existing code block.


Which window is generating the error, opener or popup?



I'm away for the next few hours. Meanwhile could you post your script - commented out block and my bit - I expect there's a simple mis-paste.

Back about 5:00 UK time.


I should have said 5:00 PM (Friday 01 Oct).