点击链接打开对话框:
<a href="javascript: return false;"
onclick="openGamePopup('.$this->gameID.')">Show details</a>
Ajax功能
function openGamePopup(gameID){
$('#standardDialog').dialog('option', 'title', 'Game Details');
if (window.XMLHttpRequest){ // AJAX nutzen mit IE7+, Chrome, Firefox, Safari, Opera
xmlhttp=new XMLHttpRequest();}
else { // AJAX mit IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("standardDialog").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","gameprofile.php?id="+gameID,true);
xmlhttp.send();
$("#gameTimePicker").css("z-index", "9999");
$('#standardDialog').dialog('open');
}
JQuery项目
$('#gameTimePicker' ).datetimepicker({
changeMonth: true,
changeYear: true,
minDate: "+0d",
maxDate: "+90d",
dateFormat: 'yy-mm-dd',
});
$("#standardDialog" ).dialog({
autoOpen: false,
width: 600,
height: 450,
}
});
并填写填充对话框内容的PHP:
if (isset($_GET['id'])) {$game= NEW Game($_GET['id']);}
$game->showPopup();
class Game{
.....
function showPopup(){
echo ' <div style="font-size:11px;" align="center">
<div><br/>Date and Time:
<input id="gameTimePicker" name="whenDate" type="date" /></div>';
echo ' <div><br/>';
}
}