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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding items when printing 4

Status
Not open for further replies.

abuthemagician

IS-IT--Management
Nov 26, 2003
192
US
I have a form i created that has a print button at the end of the form. When you click the button the form prints WITH the print button. I know in VB there is a way to hid the button just before being sent to the printer. Can this be done with html or even Javascript?
 
search this forum for print css or see thread215-825329

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
If you have a button to print the page you can call code from the button that changes the visibility or display attribute of the parts you don't want printed before you call the print method.

Don't know if there's an onBeforePrint event that you can use to do the same.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Ok. Is there a good primer or something that i can read to figure out Stylesheets?
 
I found this post, and incorporated it into my asp form, but the button still prints...

My style sheet (print.css) only has the following lines in it:

CODE
.exclude {
display: none;
}

Then i linked it in the <HEAD> </HEAD> tags
<link href="print.css" rel="stylesheet" type="text/css" media="print">

what went wrong?

Also my form is in (root)/forms and the style sheet is in (root)/stylesheet. How do I reference the style sheet that is in a separate folder under the root?


then made the button hide
CODE
<input type="submit" name="Submit" value="Submit" class="exclude">
 
Code:
<link href="print.css" rel="stylesheet" type="text/css" media="print">
should be
Code:
<link href="[COLOR=red]stylesheet/[/color]print.css" rel="stylesheet" type="text/css" media="print">

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Do you have class exclude in your regular stylesheet as well? If you do, you might consider putting the print stylesheet after that or making the default stylesheet just for screen. However, since you mention the path problem, that is probably it:
Code:
<link href="/stylesheet/print.css" rel="stylesheet" type="text/css" media="print" />
or
Code:
<link href="../stylesheet/print.css" rel="stylesheet" type="text/css" media="print" />
 
i have no regular stylesheet. what i wrote above is code i got from the link to the other post and tried to adopt it to work. I really know very little about style sheets
 
Actually, I gave you all the code you would need.

This in the page header

Code:
<style type="text/css">
body {background: pink}
@media print {
body     {background-color:none}
.noPrint {display:none}}
</style>

and this in the body

Code:
<span id="noprint">YOUR BUTTON STUFF</span>

Clive
 
but i would like to use a linked css instead as i have lots of forms to put this in
 
Give us the link to the site. There must be a simple error we're overlooking.
 
CliveC's example should be
Code:
#noPrint {display:none}}
for an id or
Code:
.noPrint {display:none}}
for a style
Code:
<span [COLOR=red]style[/color]="noprint">YOUR BUTTON STUFF</span>

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top