I want to create a print button (with other buttons) on a web page so that when the print button is clicked:
a new window is created, showing only the frame that contained the print button, then print to the printer.
The following code will create a new window, showing only the frame that contained the print button. However, how to print to the printer?
<?php
function createButton ($name, $alt, $url, $t = "")
{
echo "<!-- $name -->";
echo "<a href=\"$url\"$t>";
?><img src="/gif/<?= $name ?>1.gif"
onLoad="MM_preloadImages('/gif/<?= $name ?>2.gif')"
onMouseOut="this.src='/gif/<?= $name ?>1.gif'"
onMouseOver="this.src='/gif/<?= $name ?>2.gif'"
alt="<?= $alt ?>"
title="<?= $alt ?>"
name="<?= $name ?>"
width="50" height="10" border="0"></a>
<?
}
function createPrintButton ()
{
echo "<td>";
if ($GET["printFlag"])
createButton("btnprint", "Print", "javascript:window.print()");
else
{
$a = $SERVER["REQUEST_URI"];
$a .= strstr($a, "?") ? "&" : "?";
createButton("btnprint", "Print", $a . "printFlag=1", " target=_new");
}
echo "</td>";
}
function Print()
{
}
if ($_GET["printFlag"])
{
Print();
}
else
{
createRefreshButton();
createPrintButton();
}
?>