Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make input buttons non-printable. 6

Status
Not open for further replies.

BirdieNamNam

Programmer
Feb 12, 2004
52
SE
Dear friends!

I have some buttons on my form that I don't want to be printed when I print the page. Is it possible to hide them in the printout only?

Best regards, Sebastian
 
create a stylesheet for print media
<link href="print.css" rel="stylesheet" type="text/css" media="print">

in your style sheet have an exclude class like follows:
Code:
.exclude {
visibility:hidden;
}

then make the buttons you want to hide part of the exclude class:
Code:
<input type="submit" name="Submit" value="Submit" class="exclude">

Voila! You can see the buttons on screen, but not in print.

[cheers]
Cheers!
Laura
 
Cool!

Thank you. But this means, I have to use two sets of css:s if I want the rest to look the same on screen and on printout... Ok, I can accept this, even if it's not the best I can think of.

Thanks, Sebastian.
 

>> But this means, I have to use two sets of css:s if I want the rest to look the same on screen and on printout...

Surely not...

If you only define the ".exclude" class in the print CSS, and have your main CSS marked for both print and screen, then the exclude class would only get included when printing.

That's the theory, anyway ;o)

Dan
 
This works great! I'm using it to hide some text on a report when it's printed, but I seem to have one small problem. Even though the text shows in the browser and doesn't show when the report is printed, all of the breaks seem to be there and the actual report is positioned as if the text was there. Here's what I'm using:
Code:
<style type="text/css" media="print">
.exclude {
visibility:hidden;
}
</style>


<div align="center" class="exclude">
<h2>Preparing Reports for Printing.<br><div style="font-size: 12px; font-weight: normal;">...Please wait...</div></h2>
<br><A HREF="JavaScript: close();" OnClick=ResetHeader()>Click Here to Close this Window</A>
<br><br><br><br>
</div>
Is there any way that I can hide the text AND the breaks when printing?

Thanks!




Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
visibility: hidden just makes it "hide" it's still there just can't see it. display:none will move everything up so it seem like it was never there.

<style type="text/css" media="print">
.exclude {
display:none;
}
</style>


Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Sweet!! Thanks!




Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
I know its an old post, but thanks guys, this helped a lot.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
you can use mediums in css

like
Code:
@screen
.myClass
{
    visibility: visible;
}

@print
.myClass
{
    visibility: hidden;
}

and have your input type have myClass as CSS Class. and there's no need for any javascript

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
You know what's incredible..

I was about to ask a question here, in this post... and your answer is exactly what I needed.

Thanks, you got a star.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top