您好我有2个下拉列表(客户端和产品)和1个内容数据。产品下拉列表取决于客户下拉列表中的选择(我已经这样做了)。问题是我想根据产品下拉列表中的选择自动加载内容数据。
这是我的代码:
float dataRX= (float)TrafficStats.GetUidRxBytes(Android.OS.Process.MyUid())/(float)(1024*1024);
float dataTX= (float)TrafficStats.GetUidTxBytes(Android.OS.Process.MyUid())/(float)(1024*1024);
filter_client.php:
<script>
function filterClient(str) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("ProductOpt").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","filter_client.php?f=client&q="+str,true);
xmlhttp.send();
}
function filterProduct(str) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("content").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","filter_product.php?f=product&k="+str,true);
xmlhttp.send();
}
</script>
<table border='0' style='float: right'>
<tr>
<td>
<form>
<select name='ClientFilter' onchange="filterClient(this.value);">
<option value='0' style="text-align: center">--Filter by Client--</option>
<?php
$clientDL = mysql_query("SELECT * FROM `Client`");
while($client=mysql_fetch_array($clientDL))
echo "<option value='".$client['ClientID']."'>".$client['ClientName']."</option>";
?>
</select>
</form>
</td>
<td>
<form>
<select name='ProductFilter' id="ProductOpt" onchange="filterProduct(this.value);">
<option value='' style="text-align: center">--Filter by Product--</option>
</select>
</form>
</td>
</tr>
</table>
<div id="content"></div>
filter_product.php:
<?php
if (file_exists("../../../../wp-load.php")) {
require_once("../../../../wp-load.php");
}
$k = $_GET['k'];
global $dbhandle;//Database connection
if($q!=0) {
if (isset($_GET['f']) && $_GET['f'] == 'client') {
$productDL = mysql_query("SELECT * FROM `Product` where ProductID = " . $k);
while ($product = mysql_fetch_array($productDL))
echo "<option value='" . $product['ProductID'] . "'>" . $product['ProductName'] . "</option>";
}
}
?>