ALL :: ZONES :: How to print frame B from frame A - Urgent need !! |
|||
| By: aclausi |
Date: 07/04/2003 00:00:00 |
Points: 300 | Status: Answered Quality : Excellent |
|
I need to print the content of frame B using a print button I put in frame A. I need to detect also if the user pushed the print button in order to be sure to delete the data contained in frame B from a database. Thanks Attilio |
|||
| By: leinad | Date: 07/04/2003 16:38:00 | Type : Answer |
|
| Hi.. You can do this with JavaScript. PHP is server-side scripting so you can not detect any click on the users computer. try this code in Frame A: <input type="image" src="url/to/your/image" onClick="javascript:parent.yourFrameB.print();"> Or just the onClick part in a a-Tag or where you want... Greetings Leinad |
|||
| By: aclausi | Date: 08/04/2003 18:35:00 | Type : Comment |
|
| Hi Leinard I understand your code can print frame B but as I'm using it inside a php file, I need also a returned variable that tells if it was pressed or not the print button in order to delete some data in my database. Greetings Attilio |
|||
| By: VGR | Date: 08/04/2003 19:49:00 | Type : Comment |
|
| then enhance the leinad's solution like this : <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Hide from JavaScript-Impaired Browsers function myfunc() { parent.yourFrameB.print(); window2=window.open('./somepage.php','','width=50,height=50'); } // End Hiding --> </SCRIPT> rest of your HEAD stuff here </head> <body> your body here <input type="image" src="url/to/your/image" onClick="myfunc();"> </body> </html> and in somepage.php this kind of code : <? // perform database update connect or include the connection stuff so that you've a valid $linkID to the DB query="UPDATE sometable SET somevar=somevalue WHERE ..."; $result=mysql_query($query,$linkID) or die ("wrong query '$query', error was : ".mysql_error()); // now continue // close the window echo "<SCRIPT>self.close();</SCRIPT>"; exit; ?> that's all |
|||
| By: aclausi | Date: 08/04/2003 20:36:00 | Type : Comment |
|
| Hi,VGR your code works,also if it opens for a moment a new window , but the broblem is : as the code for printing frame B opens the printer window of the browser, the solution you suggested has no control on the fact that the user can press the cancel button instead of the press button of foresaid window and the data would be deleted in any case, while I want to delete the data on my DB only if the user will press the print button of the printer window. Greetings Attilio |
|||
| By: VGR | Date: 08/04/2003 21:17:00 | Type : Assist |
|
| no way. you can't detect (at least from javascript[clientside] of PHP[serverside]) if the print window is still there or not. NO WAY |
|||
| By: aclausi | Date: 08/04/2003 21:39:00 | Type : Comment |
|
| I am not sure but I think there is a way to detect if the print command from javascript opens or not the printer dialog box , may be it regards the way to detect which of the windows of the menu bar of Iexplorer or Netscape is opened. Attilio |
|||
| By: VGR | Date: 08/04/2003 21:41:00 | Type : Comment |
|
| in Delphi I can do this, but from javascript... No idea. I guess it's impossible given the restrictions of javascript regarding what it can do on the local machine (it can't even copy a file) |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








