0
我試圖從通過jQuery對話框加載的頁面中檢索選定的值。從jQuery對話框中加載的頁面中檢索選定的值
以下是詳細信息 - 一旦SelectTeam.php頁面已加載到對話框(已通過一些默認選擇),一旦用戶單擊對話框的「確定」按鈕,我想檢索新選擇,因爲用戶可以覆蓋默認選擇&,然後按確定。如何在按下「確定」按鈕時獲得新的選擇。
父頁 - 這是在jQuery的對話框加載
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>jQuery UI Dialog Example</title>
<link type="text/css" href="css/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
<style>
body { font-size: 62.5%; }
</style>
<script type="text/javascript">
function openDialog(url) {
$("#somediv").load(url).dialog({
modal:true,
title: 'Team Select',
width: 300,
height: 400,
autoOpen: true,
resizable: false,
buttons: {
"OK": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
</script>
</head>
<body>
<div id="somediv"></div>
<a href="#" onclick="openDialog('SelectTeam.php?TeamIds=2,4,13');">Dialog</a>
</body>
</html>
子頁面 -
<?php
$lstTeamId = array();
if (isset($_GET['TeamIds']))
{
$lstTeamId = explode(',', $_GET['TeamIds']);
}
?>
<!DOCTYPE html>
<html>
<body>
<form id="frmSelectTeams">
<table width="100%" border="1">
<tr>
<th align="center"><input type="checkbox" disabled="disabled"/></th>
<th align="center">Team Name</th>
</tr>
<?php
for ($index = 1; $index < 21; $index++)
{
echo '<tr>';
echo '<td align="center"><input type="checkbox" class="test" name="chk' . $index . '" '; if (in_array ($index, $lstTeamId)) { echo 'checked="checked"';} echo ' /></td>';
echo '<td align="center">Team ' . $index . '</td>';
echo "</tr>";
}
?>
</table>
</form>
</body>
</html>
你的複選框都應該是單選按鈕,如果你只想要一個選擇......?他們應該有與你想要選擇的值相同的值,即新的選擇網址? – Stefan 2012-03-30 09:59:55