我有一个回显按钮的表,目前这个按钮将你带到'details.php',并将£booking_id记录转移到新的php scrpit。 这是我目前的代码:
echo '<td>a href="Details.php?id='.$row['booking_id'].'"><button>View Details</button></td>';
我想要这个按钮打开一个新的弹出窗口。我如何将两者合并在一起,所以当我点击按钮弹出窗口并将'booking_id'记录结束时。我有java脚本代码:
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
<a href="JavaScript:newPopup('Details.php);">View Details</a>
答案 0 :(得分:1)
echo '<td>';
echo '<input type="button" value="View Details" onclick="JavaScript:newPopup(\'Details.php?id='.$row['booking_id'].'\')" />';
echo '</td>';
答案 1 :(得分:0)
<强>的index.php 强>
<html>
<head><title>No Head</title></head>
<body>
<?php
$rows = array(
0 => array('booking_id' => 1),
1 => array('booking_id' => 2),
2 => array('booking_id' => 3),
3 => array('booking_id' => 4),
);
echo '<table>';
foreach($rows as $row)
{
echo "\n<tr><td>";
echo '<a href="Details.php?id=' . $row['booking_id'] .'"';
echo ' onclick="javascript:popup(this.href); return false;">';
echo 'View Details';
echo '</a>';
echo "</td></tr>";
}
echo "\n</table>";
?>
</body>
<script type="text/javascript">
function popup(url) {
popupWindow = window.open( url, 'popUpWindow',
"height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes"
)
}
</script>
</html>
<强> DETAILS.PHP 强>
<html>
<head></head>
<body>
Details for ID <?php echo $_GET['id']; ?>
</body>
</html>