<html>
<body>
<?php
if(isset($_GET["pic"])){$pic_to_print = $_GET["pic"];}
switch($pic_to_print)
{
case 1:
echo "<div style='text-align:center;'>
<img src='http://www.animalmakers.com/Catalog/images/airedale_5515-01.jpg'>
<br>
<p><button onclick=\"this.style.display='none';print();document.getElementById('btn1').style.visibility='visible';\">Print</button></p>
<p><button id='btn1' style='visibility:hidden;' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 2:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';print();document.getElementById('btn2').style.visibility='visible';\">Print</button></p>
<p><button id='btn2' style='visibility:hidden;' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 3:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';print();document.getElementById('btn3').style.visibility='visible';\">Print</button></p>
<p><button id='btn3' style='visibility:hidden;' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 4:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';print();document.getElementById('btn4').style.visibility='visible';\">Print</button></p>
<p><button id='btn4' style='visibility:hidden;' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 5:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';print();document.getElementById('btn5').style.visibility='visible';\">Print</button></p>
<p><button id='btn5' style='visibility:hidden;' onclick='window.close();'>Close window</button></p>
</div>";
break;
}
?>
</body>
</html>
Is this what you mean?
Or if you want the print and close window buttons both visible at first and the close window button visible after you print, then change preview.php to this:
preview.php
PHP Code:
<html>
<body>
<?php
if(isset($_GET["pic"])){$pic_to_print = $_GET["pic"];}
switch($pic_to_print)
{
case 1:
echo "<div style='text-align:center;'>
<img src='http://www.animalmakers.com/Catalog/images/airedale_5515-01.jpg'>
<br>
<p><button onclick=\"this.style.display='none';document.getElementById('btn1').style.display='none';print();document.getElementById('btn1').style.display='block';\">Print</button></p>
<p><button id='btn1' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 2:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';document.getElementById('btn2').style.display='none';print();document.getElementById('btn2').style.display='block';\">Print</button></p>
<p><button id='btn2' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 3:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';document.getElementById('btn3').style.display='none';print();document.getElementById('btn3').style.display='block';\">Print</button></p>
<p><button id='btn3' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 4:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';document.getElementById('btn4').style.display='none';print();document.getElementById('btn4').style.display='block';\">Print</button></p>
<p><button id='btn4' onclick='window.close();'>Close window</button></p>
</div>";
break;
case 5:
echo "<div style='text-align:center;'>
<img src='Put address of next image here'>
<br>
<p><button onclick=\"this.style.display='none';document.getElementById('btn5').display='none';print();document.getElementById('btn5').style.display='block';\">Print</button></p>
<p><button id='btn5' onclick='window.close();'>Close window</button></p>
</div>";
break;
}
?>
</body>
</html>
I am sure there must be numerous ways to lay these pages out, but this is the general method used. And there may be better ways to do this, but this is simple and effective. Have fun.
I used the bottom code for my "preview.php" file because I want the "Print" and "Close Window" buttons there at the same time. It is working. However, when I choose "Print", it prints and the "Print" button goes away.
How can I make it so the buttons stay there all the time?
I figured out the answer to my last question. I have it installed and it is working flawlessly on the site.
THANK YOU SO MUCH FOR YOUR HELP.
In a perfect world, I would not need all of this. The customer would just push the "print this image" button under the thumbnail and it would just print the image. Too bad we do not live in a perfect world.
Is there anyway to automate this tho? Is it possible for the customer to push the "print this image" button and have it automatically bring up the image in a new window, bring up the print dialog, and when the print job is done, close the popup window?
yes, that is wishful thinking: the browser has no control/knowledge about anything else besides the browser. Printing is not done by the browser itself, but via drivers. You simply can't steer that process via regular scripting.
__________________ Jack Bauer makes Chuck Norris cry
Well, I don't care about the length of the script right now. It is working perfectly and it is for a specific use. If I end up using it throughout my site, then I might look for a streamlined approach.