目标:我想从Connection.php片段中的getFaculties()中检索值并将其插入到表单上的server {
listen 80;
server_name *.example.com;
....
}
我的表格代码
<select>
这是执行请求的功能......
<form id="myform" method="GET">
<label>Varsity Name</label><br>
<select name="selVarsityName" id="selVarsityName" onchange="dropUpdate();">
<?php
require 'Connection.php';
$conn->getVarsities();
?>
</select><br>
<label>Faculty Name</label>
<select name="selFaculty" id="selFaculty">
</select><br>
这是Middle.php页面上的代码。
function dropUpdate() {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('selFaculty').innerHTML = xmlhttp.responseText;
}
};
var ghgh = document.getElementById('selVarsityName').value;
xmlhttp.open('GET', 'Middle.php?selVarsityName=' + ghgh, true);
xmlhttp.send();
}
我的Connection.php页面上的代码
require './Connection.php';
if (isset($_GET['selVarsityName'])) {
$selVarsityName = $_GET['selVarsityName'];
$conn->getFaculties($selVarsityName);
}