473,498 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript - How can I not print control objects, like buttons on a page?

110 New Member
I have a web app that displays insurance premium quotes. I want to be able to designate certain items, like buttons, that will not print if the user prints the screen. I have tried <div class="noPrint"></div>, which had no effect. Any suggestions?
Feb 8 '07 #1
4 2040
dmjpro
2,476 Top Contributor
i think u r moderately sound in js...
u know window.print()
but it prints the whole page...
but ur goal is to print specific elements of page...
before call window.print try to do one thing ....
hide the elements ...

ur HTML code ....
<input id = e_id1>

ur JS code ............
--------------
--------------------
document.getElementById('e_id1').style.display = 'none'
window.print()
document.getElementById('e_id1').style.display = 'block'
----------------
-----------------

then see the magic ....
best of luck
Feb 8 '07 #2
mrhoo
428 Contributor
Write two stylesheets for you page, like this:
<link rel="stylesheet" type="text/css" media="screen" href="css/hooview.css">
<link rel="stylesheet" type="text/css" media="print" href="css/hooprint.css">

For the stylesheet with media="print" set the elements you don't want to print to display="none"

button,input,select,textarea{display:none}
.noprint *{display:none}
#noprintDiv{display:none}

Note- if you set the display of any of these items with javascript you will need to reset their display to '' (empty string, default to stylesheet) before you print.
Just avoid scripting for the display styles of these elements
Feb 8 '07 #3
dmjpro
2,476 Top Contributor
thanks for new conception.....
Feb 8 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
An old, but useful article.
Feb 9 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7210
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.