Click to See Complete Forum and Search --> : Printing with JavaScript: Excluding form
Goodz13
December 12th, 2002, 12:36 PM
It it possible to have JavaScript print the page and exclude a form that's on the page?
I have a print button on the page with the following code
<input type="button" name="print" value="Print" onClick="javascript:window.print()">
and I don't want it to print the "Print" Button or another Submit Button that I have on the page.
Is that possible?
Derrick
websmith99
December 12th, 2002, 04:05 PM
You can do this using CSS2:
<html>
<head>
<style type="text/css">
@media screen
{
.myButtons {visibility: visible;}
}
@media print
{
.myButtons {visibility: hidden;}
}
</style>
</head>
<body>
<form>
This button should not print
<input type="button" class="myButtons" value="Print" onClick="window.print()">
</form>
</body>
</html>
This will work on IE6+ and NN6+
:cool:
Goodz13
December 12th, 2002, 11:26 PM
Execelent thanks!
Venkatas
December 18th, 2002, 06:53 AM
Call another funtion at the OnClick event, in this function set both the buttons Style.Visibility to "Hidden" and call the print method. Once the print method returns then set the Visibility to "Visible".
See the following code, make the changes according to our requirement.
OnClick = PrintReport()
PrintReport()
{
window.form1.PrintButton.style.visibility = "hidden";
window.print() ;
window.form1.PrintButton.style.visibility = "visible";
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.