PHP JavaScript:弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22735188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 23:41:47  来源:igfitidea点击:

PHP JavaScript: PopUp Window

javascriptphphtmlweb

提问by user3247335

I have a table which echos a button, currently this button takes you to the 'details.php' with £booking_id record taken over to the new php scrpit. Here is my current code:

我有一个显示按钮的表格,目前这个按钮会将您带到“details.php”,将 £booking_id 记录转移到新的 php scrpit。这是我当前的代码:

echo '<td>a href="Details.php?id='.$row['booking_id'].'"><button>View Details</button></td>';

I would like this button to open a new popup window. How do i merge the two together, so when i click the button the popup window and takes the 'booking_id' record over. i have the java script code:

我想要这个按钮打开一个新的弹出窗口。我如何将两者合并在一起,所以当我单击按钮弹出窗口并接收“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>

回答by mangovn

echo '<td>';
echo '<input type="button" value="View Details" onclick="JavaScript:newPopup(\'Details.php?id='.$row['booking_id'].'\')" />';
echo '</td>';

回答by Jens A. Koch

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

详细信息.PHP

<html>
<head></head>
<body>
Details for ID <?php echo $_GET['id']; ?>
</body>
</html>