• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

How do I use javascript to close and then completely refresh the parent window?

I've got a problem with what should be a simple javascript refresh!

I have a table where the user can delete a record. When they select delete, they are presented with a popup confirmation window.

When the user confirms, the record should be deleted (this works perfectly), and the popup window should close (this also works perfectly), and finally the parent window should refresh removing the deleted record from the table.

This is the part that does work. I've tried all sorts of combinations of the following code and I've no idea what I'm doing wrong since the parent seems to refresh a little, but there is no change to the page. If I then refresh manually, the table updates and the deleted record disappears.

Ideas what could be the problem?
<form action="" method="post" name="confirm_delete" target="_parent" id="confirm_delete" onclick="self.close(); window.opener.location.reload();" alt="refresh">
        <label>
        <input type="submit" name="Delete" id="Delete" value="Remove Guest" />
        </label>
        <input name="guestid" type="hidden" id="guestid" value="<?php echo $row_guest_select_remove['guestid']; ?>" />
      </form>

Open in new window

0
beanbaguk2
Asked:
beanbaguk2
  • 4
  • 4
  • 2
2 Solutions
 
quincydudeCommented:
try
parent.opener.location.reload();

btw would it be better if the onclick is triggered on form on submit?
0
 
beanbaguk2Author Commented:
Hi quincydude,

No joy unfortunately. It has the same result as before.

I'm also wondering what you meant by your second statement with regards to the onclick trigger.....

Cheers,

BB
0
 
SreejithGCommented:
//refresh parent window
window.opener.location.reload();
// close self
window.close();
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
SreejithGCommented:
The above code shuld be used in the popup page.
0
 
beanbaguk2Author Commented:
Hi again there SreejithG!

Could you elaborate on that please? Should it be in a function?

Cheers,

BB
0
 
SreejithGCommented:
Say you have a button to close the child window. Call the function on click of the button
See the sample below
<HTML>
<HEAD>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function buttonClose_onclick() 
{
	if(window.opener)
		window.opener.location.reload();
		
	window.close();
}
 
//-->
</SCRIPT>
</HEAD>
<BODY>
<p>
<input type="button" value="Button" id=buttonClose name=buttonClose LANGUAGE=javascript onclick="return buttonClose_onclick()">
</p>
</BODY>
</HTML>

Open in new window

0
 
beanbaguk2Author Commented:
I've done exactly what you mentioned and have the same problem still.

Only this time it takes 2 attempts to remove the record. I've no idea what's going on there......

I need to hit the sack as it's 2:25am here and I've got work at 7am!!!!

I'll catch up with this in the morning.

Cheers,

BB
0
 
quincydudeCommented:
beanbaguk2,

what i meant was not to use onclick but onsubmit

onsubmit="self.close(); window.opener.location.reload();"

as the onclick will be triggered every time the form is being clicked...


0
 
SreejithGCommented:
please provide full page so that I can get more idea on what u r trying
0
 
beanbaguk2Author Commented:
I found an alternative solution. Although what was posted was correct, my circumstances were different and another method was needed. Thanks for the help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now