我有一组复选框“框”现在我希望我的下拉列表根据从数据库中检索点击的复选框显示名称。
代码:
$sql = "Select distinct empname from mstEmp where teamtype='$d' order by empname";
$objDB->SetQuery($sql);
$res = $objDB->GetQueryReference();
if(!$res)
exit("Error in SQL : $sql");
if($objDB->GetNumRows($res) > 0)
{
while($row = mysql_fetch_row($res))
{
print("<option value='{$row[0]}'>{$row[0]}</option>");
}
}
mysql_free_result($res);
答案 0 :(得分:0)
1.select.jsp
<%@page import ="java.sql.*" %>
<html>
<head>
<script type="text/javascript">
function showData(){
if (document.form.check.checked==true){
xmlHttp=GetXmlHttpObject()
var url="select2.jsp";
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}
function stateChanged(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("name").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject(){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>
<body>
<form name="form">
<br><br>
<input type="checkbox" id="check" onclick="showData();">
<div id='name'>
<b>Select Data</b>
<select name='name' >
<option value='-1'></option>
</select>
</div>
</form>
</body>
</html>