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.

HELP!!

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

Richard,

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

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

Airshow

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 -->
</script>

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() 
{ 
window.location.reload(); 
} 
//--></script>

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) {
window.opener.location.reload();
} ;">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?

Richard,

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
	ff.push('toolbar=0');
	ff.push('scrollbars=1');
	ff.push('location=0');
	ff.push('statusbar=0');
	ff.push('menubar=0');
	ff.push('width=805');
	ff.push('height=575');
	ff.push('left=470');
	ff.push('top=200');
	ff.push('resizable=0');
	ff.push('scrollbars=no');
	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 ......

Airshow

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.

Airshow

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; eSobiSubscriber 2.0.4.16; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C)
Timestamp: Fri, 1 Oct 2010 12:01:16 UTC


Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://www.domain.com/staff/tpr/view_tpr.php?tpr_reference_number=1061160

Which window is generating the error, opener or popup?

Airshow

Andrew,

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.

Airshow

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.