Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2004, 12:30 PM
Authorized User
 
Join Date: Jul 2003
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>

 
Old February 18th, 2004, 12:36 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
 
Old February 18th, 2004, 12:43 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank You Imar ;)






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





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