printing only selected section

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
amrita2084
Forum Newbie
Posts: 6
Joined: Tue Apr 01, 2008 6:04 am

printing only selected section

Post by amrita2084 »

hi every1
i would like to know how to print only selected section in a page using javascript? the values to b printed is retrieved from database using php and mysql. so how to print only those content instead of the whole page.

any kind of help will be appreciated.

thanks in advance.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: printing only selected section

Post by Jade »

I'm not exactly sure what you mean. It sounds like you're trying to use AJAX but I'm not quite sure. You can hide parts of a page (even if the page is there) using CSS and the div and layer hidden properties as well.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: printing only selected section

Post by RobertGonzalez »

Moved to Client Side.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: printing only selected section

Post by JellyFish »

What do you mean by printing? Do you mean like printing paper? If you mean printing paper, then I don't think there's anyway for you to control if the client wants to print the entire page or the selected part.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: printing only selected section

Post by Sindarin »

I think he means to select a region xmin,xmax,ymin,ymax and print that instead of the whole page.
I am not sure, but you could try a combination of css and ajax.
Otherwise if you're not looking for something dynamic, you could go with css as mentioned or even try placing the following <link> tag in your document head:

Code: Select all

<link rel="alternate" media="print" href="printing-region.html" />
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: printing only selected section

Post by RobertGonzalez »

The easiest thing to do, when it comes to printing a page, is to use a print stylesheet. There is no need for javascript.
Post Reply