CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 window.close with return confirm problem when closing a popup

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 03/07/2005, 3:48 AM

I am currently having an issue with closing a popup window. I want to be able to fill in the popup then select save. At this point a message appears stating 'are you sure you wish to save this record?' click OK and the popup window closes click CANCEL and the window stays open.

I have added the following Java function code to the Onclick event client side.

function closewindow()
{
return confirm('Are you sure you wish to save this record?');
window.close();
}


The first part of this works fine (the message appears) but when I click OK the page does not close and a page cannot be found error message appears.

To fix this I changed the function to the following code.

function closewindow()
{
confirm('Are you sure you wish to save this record?');
window.close();
}

By changing the Return confirm to just Confirm the message appears I click OK the popup close. Great! But if I Click CANCEL the page also closes!

Has anyone had the same problem or knows of a way round this?

Any help would be much appreciated

kind regards

Rob
View profile  Send private message
eiden


Posts: 34
Posted: 03/07/2005, 7:24 AM

  
<SCRIPT LANGUAGE="JavaScript">  
function CloseWindow() {  
  
if (confirm('Are you sure you wish to save this record?')) {  
window.close();  
}  
}  
</SCRIPT>  
  
  
<A HREF="" onclick="CloseWindow();return false">Confirm & Alert</A>  
View profile  Send private message
robn

Posts: 70
Posted: 03/07/2005, 8:11 AM

Thanks for the Code eiden

This works fine when using a hyperlink but no data is been saved.

What I am trying to do is use the Save/Submit button. When I select OK from the confirm message the record is saved/updated and the popup is closed. When I select cancel the page remains the same with no data saved (but any changes that are made to the screen stay on the screen i.e. a date change). I am also unsure as to what if anything I should put in the return page of the button?

As I have been typing this I think I have found the solution the following code appears to work

function closewindow()
{
var result;
result = window.confirm('Are you sure you wish to save this record?');
if (result == true){
document.form_name.submit();
window.close();
}
else {return false;
}
}

I changed the button properties to the following

<input name="{Button_Name}" onclick="closewindow();" type="button" value="Save"

And it now appears to work as intended.

When I click OK the record is saved/updated and the window close. when I click Cancel I get returned to the form with any changes still showing but the data has not been saved.

So all appears to be working

Thanks for your help

Rob
View profile  Send private message
Oper


Posts: 1195
Posted: 03/08/2005, 4:31 AM

Quote :
What I am trying to do is use the Save/Submit button. When I select OK from the confirm message the record is saved/updated and the popup is closed. When I select cancel the page remains the same with no data saved (but any changes that are made to the screen stay on the screen i.e. a date change). I am also unsure as to what if anything I should put in the return page of the button?

You could do this with CCS without even creating a single word of code.
1) Click The SAve Button
2) GOto events
3) Clien - (on CLick) [RIght Click Here]
4) Click Add Action
5) Select Confirm Message

That's all


_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
robn

Posts: 70
Posted: 03/08/2005, 4:43 AM

Quote :
You could do this with CCS without even creating a single word of code. 1) Click The SAve Button
2) GOto events
3) Clien - (on CLick) [RIght Click Here]
4) Click Add Action
5) Select Confirm Message

Hi I did try doing that at first but it does not close the popup window. When I tried adding a window.close command to it and selected OK the record saved but the page did not close and an error message appeared.
View profile  Send private message
Oper


Posts: 1195
Posted: 03/08/2005, 5:12 AM

OK, i see now.

First the Confirmation message is Client Side, so you cant save before closing the window doing like this.

Suggestion:

Instead of Closing the window after click, before save call the same page.asp with any parameters like ?CloseNow=1

So basicly the page will reload again but with 1 parameter, now you should check that parameter during init and just close the window if that parameter was on the URL.

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Tuong Do
Posted: 03/09/2005, 9:57 PM

Hi Robn

First create a Page called SelfClose, on the (Client side) onload of this
page
<code>
window.openner.focus();
window.close();
</code>


Then on the popup window

Client side
1) Click The SAve Button
2) GOto events
3) Clien - (on CLick) [RIght Click Here]
4) Click Add Action
5) Select Confirm Message

Then on the Save button of the popup page, make the Return page be the
SelfClose page that you create above

What it mean is it will redirect your popup page to the Selfclose page when
the save is OK
The SelfClose will close itself.





"robn" <robn@forum.codecharge> wrote in message
news:6422c3f8f70e21@news.codecharge.com...
>I am currently having an issue with closing a popup window. I want to be
>able to
> fill in the popup then select save. At this point a message appears
> stating 'are
> you sure you wish to save this record?' click OK and the popup window
> closes
> click CANCEL and the window stays open.
>
> I have added the following Java function code to the Onclick event client
> side.
>
> function closewindow()
> {
> return confirm('Are you sure you wish to save this record?');
> window.close();
> }
>
>
> The first part of this works fine (the message appears) but when I click
> OK the
> page does not close and a page cannot be found error message appears.
>
> To fix this I changed the function to the following code.
>
> function closewindow()
> {
> confirm('Are you sure you wish to save this record?');
> window.close();
> }
>
> By changing the Return confirm to just Confirm the message appears I click
> OK
> the popup close. Great! But if I Click CANCEL the page also closes!
>
> Has anyone had the same problem or knows of a way round this?
>
> Any help would be much appreciated
>
> kind regards
>
> Rob
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.