Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  185] [ 3]  / answers: 1 / hits: 23204  / 15 Years ago, tue, july 7, 2009, 12:00:00

I have a php page which has a chart, a date picker(calendar) and a few buttons.



I want to add another button Print Chart which ONLY prints the chart & not the entire page
,in a local printer.



I am trying to do this by a having another script(which only outputs a chart) and using the javascript function 'window.print'



html



<input type=button onClick=printChart()   value=Print Chart>


javascript



function printChart(){

var myParameters = window.location.search;// Get the parameters from the current page

var URL = http://my_server/my_folder/my_script_that_outputs_only_my_chart.php+myParameters;

var W = window.open(URL);

W.window.print(); // Is this the right syntax ? This prints a blank page and not the above URL
}


I tried the above code - it doesnt work. A blank page gets printed.



Is there a way to print a target URL ? If yes, is it possible to print it without having to open a new window ?



Thanks for your time


More From » url

 Answers
12

You could use a print stylesheet...




<link rel=stylesheet type=text/css media=print href=print.css />


...in addition to your normal style sheet. In print.css, just make everything display: none; except what you want to print.


[#99173] Thursday, July 2, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
khalilb

Total Points: 173
Total Questions: 110
Total Answers: 105

Location: Honduras
Member since Thu, Mar 23, 2023
1 Year ago
;