Forum Moderators: open
<?php
if (isset($_POST['print']) && ($_POST['print'] =='Print form'))
{
$recordID = $_POST['recordID'];
header('Location: print_form.php?recordID='.$recordID);//send to print page//
} else {
if (isset($_POST['edit']) && ($_POST['edit'] =='Edit form'))
{
$recordID = $_POST['recordID'];
header('Location: customer_edit.php?recordID='.$recordID);//send to edit page//
}
}
?>
echo '<meta HTTP-EQUIV="REFRESH" content="0; url=print_form.php?recordID='.$recordID.' "target="_blank">';
<form action="whatever.php" method="post">
<input type="hidden" name="recordID" id="recordID" value="1234">
<p><input type="submit" id="editButton" value="Edit"></p>
<p><input type="submit" id="printButton" value="Print"></p>
</form>
<script type="text/javascript">
window.onload=function() {
var p = document.getElementById('printButton');
if (p) { p.onclick=function() { printWindow(this.form); };
};
//
function printWindow(frm) {
if (frm.recordID) {
var day=new Date();
var id=day.getTime();
var url = 'print_form.php?recordID='+frm.recordID;
window.open(url,id);
return false;
}
</script>
setting the target attribute would require less work, though, and would be easier to maintain.
But is invalid for XHTML doctypes
window.onload = function() {
var p = document.getElementById('printButton');
if (p) {
p.onclick = function() {
this.form.target = "_blank";
};
}
};
window.onload = function() {
var e = document.getElementById('editButton'),
p = document.getElementById('printButton');
if (e) {
e.onclick = function () {
this.form.target = "";
}
}
if (p) {
p.onclick = function () {
this.form.target = "_blank";
};
}
};