Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2004, 12:30 PM
Authorized User
 
Join Date: Jul 2003
Location: Urbana, IL, USA.
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default don't want some object/text to print with page

I don't want some added instructional text to print with a form I need the user to sign. I found a script I thought I could modify for my needs, but the script does not work. Help...

<head>
<style type="text/css">
 @media print { #DontPrint { display:none }}
</style>
</head>

<body>
  <input type="button" name="PrintIt" value="Print This">
  <p>&nbsp;</p>
  <input type="button" name="DontPrint" value="Should Not Print">
</body>

Reply With Quote
  #2 (permalink)  
Old February 18th, 2004, 12:36 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

The #DontPrint refers to the ID of an object on your page; not the name.

This should work:
Code:
<body>
  <input type="button" name="PrintIt" value="Print This">
  <p>&nbsp;</p>
  <input type="button" id="DontPrint" name="DontPrint" value="Should Not Print">
</body>
A more reusable approach is to create a custom class:
Code:
<style type="text/css">
 @media print { .DontPrint { display:none }}
</style>
Note that I changed the # to .

Now you can apply this class to multiple objects on the page:
Code:
<body>
  <input type="button" name="PrintIt" value="Print This">
  <p>&nbsp;</p>
  <input type="button" class="DontPrint" name="DontPrint" value="Should Not Print">
  <input type="button" class="DontPrint" name="DontPrint2" value="Doesn't Print Either">
</body>
HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old February 18th, 2004, 12:43 PM
Authorized User
 
Join Date: Jul 2003
Location: Urbana, IL, USA.
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank You Imar ;)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print a page without changing page setup nrajeshatwork Servlets 1 May 23rd, 2007 10:09 AM
How to Print Datagrid Object in vb.net 2002 kau_shuk VS.NET 2002/2003 0 July 26th, 2006 12:32 PM
print the hidden page without the print dialog box kayzem Classic ASP Basics 0 April 21st, 2005 11:31 PM
how to print multiple text page jgiang Java GUI 0 June 28th, 2004 05:58 PM
How can I print MsChart.object in landscape? all21 Beginning VB 6 0 December 10th, 2003 04:48 AM



All times are GMT -4. The time now is 06:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.