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 && !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?