CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How do I close a window via javascript rather than redirect in CCS 3.0.4.6

Print topic Send  topic

Author Message
mljonzs

Posts: 124
Posted: 06/16/2006, 2:48 PM

In integrating some code charge generated pages with non-code charge asp pages, I used the javascript open method to open up my CCS ASP page like this:

child=open('QuoteLineOptions/Option_List.asp?qn=<%=strQuoteNum %>&ln=<%=strLineNum %>&model=<%=strModel %>','optionMaint','resizable=yes,scrollbars=yes,width=700,height=500,top=100,left=200');

After running the code charge application I want the Option_List.asp page to close the browser window thus returning user to the originating page. If I put a value in the Return Page data property , Code charge simply returns me to the same page I started on but in the newly opened browser window so that now I have two instances of it open and I don't want to do this. How or where do I place code in code charge to allow me to refresh to parent page and close the child window? ie
window.parent.location.reload();  
window.close();

Thanks!
_________________
What does not begin WITH God, will end in failure!
View profile  Send private message
peterr


Posts: 5971
Posted: 06/16/2006, 3:46 PM

I would just modify the button that you want to work differently. For example change:
<!-- BEGIN Button emps_Update --><input type="image" src="Styles/Oak/Images/en/ButtonUpdate.gif" name="emps_Update"><!-- END Button emps_Update -->

to:
<!-- BEGIN Button emps_Update --><input type="image" src="Styles/Oak/Images/en/ButtonUpdate.gif" name="emps_Update" onclick="javascript:window.parent.location.reload();window.close();"><!-- END Button emps_Update -->

I haven't fully tested this so it's just an idea at this stage.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
marcwolf


Posts: 361
Posted: 06/16/2006, 4:25 PM

Hi Mljonz

This is something we do a lot of in a variety of forms

Now - a couple of questions.

1. When you open your new window is it an actual popup.. or does it appear in the same window.

If it is a popup then you should be using this

window.opener.location.reload();

If you are using an iframe to contain your 'pop-up' then the

window.parent.location.reload()

is correct as the parent of the iframe is the window it is on.

With this type of work there are 2 frames (no pun here) of mind. Opening a popup will work however it meand that there are now 2 instances of the browser running. And the time it takes for the new instance to initialise and load on the clients machine. Also many anti spyware etc will block popups.

The other way is to use a iframe and load the popup screen into that. This means that there are no addidtional instances of the browser and back and forth communication between the child and the parent can be a lot similer. You can easily have code that will hide the iframe when not in use, show it, reposition it, and also resize it to fit the popup page.

I hope this will give you some pointers on using popups and iframes.

Let me know if you want some examples etc.

Take Care

Dave


_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
mljonzs

Posts: 124
Posted: 06/19/2006, 6:39 AM

Peter,

I tried simply modifying the Submit button as you suggested but it didn't work. I then modified what you suggested to use window.opener.location.reload() as Dave suggested because it is a popup window - separate instance of browser and that also did not work.

The real only reason I used a popup window is because we have another area of our application that does this and works, although slightly differently and I needed to pass information back to the calling window and place it on the calling form as hidden fields but it only worked when I did it as a popup window. (I'm not too good with web programming yet as you can probably tell). For all I know, perhaps our other page does use iframe??

Basically, I am trying to do two things on the popup window when user clicks either submit or cancel -- first, I want the DB transaction to process for submit or cancel for cancel and secondly, I need the popup window to close and refresh the calling/parent window with any DB changes.
_________________
What does not begin WITH God, will end in failure!
View profile  Send private message
peterr


Posts: 5971
Posted: 06/19/2006, 10:27 PM

Possibly your JavaScript is incorrect then. You asked where do you place your JavaScript code and I just Googled for it: http://www.google.com/search?hl=en&lr=&safe=off&q=butto...ascript+onclick

However, I don't know if your JavaScript syntax is correct, therefore you may want to Google for the functionality that you need: http://www.google.com/search?hl=en&lr=&safe=off&q=butto...nt+close+window
You'll find many examples that work and can be tested online.
(although I don't know what do you mean by "didn't work")
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
mljonzs

Posts: 124
Posted: 06/20/2006, 6:55 AM

Hi Peter,

I apologize, I should have been more specific in my previous post. When I say it didn't work what I mean is that regardless of the javascript code I put on my submit button, I still kept getting directed back to my Return Page in the same browser window. It seemed like it was ignoring the javascript code altogether and defaulting to the Redirect generated by Code Charge. I was finally able to get the window to close by placing a button outside of the CCS record form (I put it on a grid that was on the same page) . Doing this allowed me to use the javascript in the on-click to refresh the "parent" and close the child window. What it still didn't allow me to do is submit the record data on the page and close the window all in one button. If I could figure out how to do that, I'd be very happy.

Thanks for you input and help! I know I can be difficult to understand at times due to my inexperience!

Michelle
_________________
What does not begin WITH God, will end in failure!
View profile  Send private message
peterr


Posts: 5971
Posted: 06/20/2006, 6:46 PM

Michelle,
Possibly you applied the JavaScript to a wrong button?
I just tested the solution that I and Dave provided above and it works perfectly for me: closes the current pop-up window and refreshes the parent window.
The JavaScript that I assigned to the Submit button is the version from Dave:
onclick="javascript:window.opener.location.reload();window.close();"
And reverse order also works for me:
onclick="javascript:window.close();window.opener.location.reload();"

And I find it not possible that this solution wouldn't work and that JavaScript can be ignored. Web browsers cannot simply ignore JavaScript and do nothing, so I can only assume that you applied the JavaScript to a wrong button, or placed it in a wrong place in HTML, etc.
And I can only recommend being very careful about following the above solution. Even if JavaScript doesn't work something should happen, either a JavaScript error message or error icon shown.

And in terms of debugging I would recommend using any JavaScript, even a msgbox that displays something - just to verify if your JavaScript works at all wherever you place it.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
mljonzs

Posts: 124
Posted: 06/21/2006, 7:14 AM

Hi Peter,

Thanks for the input! I did have the correct javascript and I was able to get it to work on a button placed on the grid, but not on a button in the record form like I said. However, Helen from support sent me information and sample code to put the javascript into the After Update event of the record form button. When I did that, it worked perfectly!

	response.Write "<script language=""javascript"">window.opener.location.reload();window.close();</script>"  
        response.end

Thanks for your help!
Michelle
_________________
What does not begin WITH God, will end in failure!
View profile  Send private message

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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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