How do you print part of a page in Javascript?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Aug 2007
Posts: 1
Reputation: amjones is an unknown quantity at this point 
Solved Threads: 0
amjones amjones is offline Offline
Newbie Poster

How do you print part of a page in Javascript?

 
0
  #1
Aug 20th, 2007
We are offering a coupon for a free soft drink to everyone who fills out our survey. When the user hits the Submit button at the end of the survey, a page appears with the coupon and a Print button. Currently, the whole page prints, including headings and links. I would like to print only the coupon. This is made trickier by the fact that the coupon is customized for each person with the person's name and the date. All help will be greatly appreciated.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: How do you print part of a page in Javascript?

 
0
  #2
Aug 21st, 2007
Don't provide the print option on the coupon page. Instead create a 'print view' button at the bottom which will take the user to a page without any frills with just the coupon. I don't know what kind of technique or server side language you are using to persist the user information, but with a bit of hacking, you should be able to easily manage it.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: How do you print part of a page in Javascript?

 
0
  #3
Aug 23rd, 2007
You can't control functions which belong to the owner of the computer that is viewing your page.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: How do you print part of a page in Javascript?

 
0
  #4
Aug 24th, 2007
> You can't control functions which belong to the owner of the
> computer that is viewing your page.
I don't think this is a question of 'controlling the functions of the owner', its rather a question which deals with the selective content which has to be served to the customer, so that the print function prints only the relevant part of the page.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: How do you print part of a page in Javascript?

 
0
  #5
Aug 25th, 2007
What I was thinking is that he wanted to do the equivalent of "print selection" with his code making the selection and choosing the "print selection" option in the Print menu.

That belongs to the user.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: How do you print part of a page in Javascript?

 
0
  #6
Aug 30th, 2007
I just checked out three coupon pages provided by well-known companies. All of them print the print button on the paper next to the coupon.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 16
Reputation: plasmafire is an unknown quantity at this point 
Solved Threads: 0
plasmafire plasmafire is offline Offline
Newbie Poster

Re: How do you print part of a page in Javascript?

 
0
  #7
Sep 4th, 2007
No problem at all, just have the browser open a new page (upon clicking print)

window.open("your page here")
pass the parameters that you need..
i,e. the coupon is customized for each person with the person's name and the date

window.open("yourPage.htm?customername=xxx&date=yyy")

After the page renders with the coupon,
call
document.print() in yourPage.htm
and maybe close the window after the page prints. and voila, one happy customer
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: How do you print part of a page in Javascript?

 
0
  #8
Sep 4th, 2007
Better solution: use CSS. With CSS you can create a stylesheet dedicated to printing which is separate from the regular page display. This way you can use CSS to remove the parts of the page you don't want printed and even reformat the parts you do want printed. All major browser support this and it is not turned off as JavaScript often is.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC