ecsMike
Posts: 40
|
| Posted: 07/09/2009, 9:30 AM |
|
I have developed an application that utilizes an Editable Grid to process items in a database. After the update / insert is completed the application returns to the Editable Grid page. I would like to be able to open a Confirmation page (in a new window) that will allow the user to print a Confirmation or simply close the page. I had no trouble developing the Confirmation page but cannot find a way to open it and still have the application return to the Editable Grid page.
I have repeatedly tried echoing Javascript that uses window.open but the window does not open and the applicaiton does not return to the Editable Grid (just shows a blank white page).
Does anyone have suggestion on how to accomplish this?
Thanks . . . Mike
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 9:39 AM |
|
Hl
Since CCS is a template driven system you cannot echo anything to have it appear in your actual web page.
What is happening is your echo is removing the CCS generated page template and producing your blank page.
If you want to put some javascript into your page dynamically, put a label on the page and put the javascript into the label.
Or
Manually edit your HTML and put a template variable like {MyJavascript} and use the $Tpl opject to put your javascript into that template variable.
You would do either of these things in the befoer show event.
Hope that helps
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 9:45 AM |
|
Hmmm
Maybe if it is a confirmation page .. you might do the javascript insert in the after update and after insert event instead of before show..
Just a thought
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ecsMike
Posts: 40
|
| Posted: 07/09/2009, 9:54 AM |
|
Thank you so much for your reply.
I am relatively new at this and do not understand how to do what you have suggested.
For clarification - I am not trying to build a link on the page to open the Confirmation page but trying to open it in a new window once the update / insert has happened. I need to populate the confirmation page with some of the same data that is being inserted in a table.
Could you please elaborate on what to put in the Template variable, how to load it and then how to execute it. Or point me to a source where I can research it if you are too busy to answer that many questions.
Again - thank you very much . . . Mike
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 9:55 AM |
|
I do not want to possibly insult you but I will give you the code to do this just in case you need it.
Since you want to use a window.open() and have it appear as a confirmation page I assume after a client signs up or something, I am guessing this is what will work for you.
In your HTML somewhere in white space in the <head></head> area... Put This Code:
<script lang="javascript" type="text/javascript>{MyScript}</script>
In both the after update and after insert event for your grid/record place this Custom Code:
//Create Dynamic Javascript
global $Tpl;
$myJavascript="window.open('confirm.php');";
//You can keep adding to this string if your javascript needs more lines
$Tpl->SetVar("MyScript",$myJavascript);
Hope that helps
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 10:01 AM |
|
BTW. Be sure the white space is not already inside a set of script tags.
Bet place might be just above the </head> tag
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 10:05 AM |
|
Let me know if that works.
I thinking about it, Not sure the template will be available in those events. They should be but if not, We might have to do something a little different. But what you want to do is certainly possible.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ecsMike
Posts: 40
|
| Posted: 07/09/2009, 10:27 AM |
|
Certainly you did not insult me - I am completely lost on this and appreciate you taking the time to try to help me.
I tried what you suggested and the application does return to the proper page but the Confirmation page never opens. I have tried this in both IE7 and FF with popup blockers turned off.
There really is no After Insert Event for this Editable Grid because the only data being inserted by the application is being inserted into another table and that is being done in the OnValidate Event. The After Update Event does exist for this Editable Grid.
In this application the user is presented with a Grid that contains some real estate listing data. The user can either check a checkbox to Decline or the user can click an Edit button opening a hidden Textbox in the grid and insert a Name. In either case the user then clicks an Update button and the data is inserted in an Event table and the Listing table is updated. The Grid is rebuilt and that listing does not reappear. I need to be able to open a Confirmation page with much of the same data that was inserted in the Events table as well as some static data and allow the user to print it - in the case where the Name was added but not in the case where the Decline checkbox was checked. I can determine which action was taken by the value of a Session Variable.
I followed your advice - but probably made a mistake. Here is what I did:
In the HTML for the Editable Grid I placed:
<script lang="javascript" type="text/javascript">{MyScript}</script>
just before the </head> tag.
Then in the After Execute Update Event for the Editable Grid I added:
global $Tpl;
//Create Dynamic Javascript
$myJavascript="window.open('Confirmation.php','ConfirmWindow');";
//You can keep adding to this string if your javascript needs more lines
$Tpl->SetVar("MyScript",$myJavascript);
I'm certain this is being executed numerous times (once for each row in the grid) but that should not cause a problem.
As I indicated the Confirmation.php window does not open at all althought the page does return properly.
Do you have any further suggestions? - or see something I did wrong?
I would be happy to email you a link to view the application and get a better idea of what it is doing.
Mike
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 10:39 AM |
|
Sure Send me the link.
The code looks OK.
Try it in the onvalidate event..
instead of after update row
If that does not work it means that tyhe page template is not available during those events and what will need to be done is something like this:
Take the $Tpl code out of the on valiadate and after update events.
Put this into the before show event:
//Second Try LOL In the Before Show Event Now.
global $Tpl;
global $isUpdaded;
$myJavascript="";
if($isUpdated){
//Create Dynamic Javascript
$myJavascript="window.open('Confirmation.php','ConfirmWindow');";
//You can keep adding to this string if your javascript needs more lines
}
$Tpl->SetVar("MyScript",$myJavascript);
Then in your on validate or after update or any place you are sure the records are being updated or inserted. (probably in on validate after everything is validated OK) Add:
//Tell before show to put javascipt in
global $isUpdated;
$isUpdated=true;
Let me know if that is better
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ecsMike
Posts: 40
|
| Posted: 07/09/2009, 11:11 AM |
|
Thank you for the reply.
I can get it to work - somewhat - by doing as you suggested although I had to place the code in the Page->BeforeShow Event. It works in FireFox with the PopUp blocker Off but does not work in IE7 at all (with PopUp blocker off). Unfortunately the individuals using the application will all be using IE7.
Any ideas?
Mike
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 07/09/2009, 12:05 PM |
|
Maybe try moving the javascript with the template variable from the head section ti right after the <body> tag.
Also in IE 7 be sure the little javascript error flag is not up.
After you do that, in the browser do a view source and be sure the javascript is correct.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
ecsMike
Posts: 40
|
| Posted: 07/10/2009, 8:50 AM |
|
[CLOSED]
Thank you jjrjr1 so much!!! I found the problem that was causing the ie7 problem. Everything is now working. I am very appreciative.
Mike
|
 |
 |
damian
Posts: 838
|
| Posted: 07/10/2009, 6:16 PM |
|
mike please post your fix in case others face this problem in the future....
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |