2012-07-12 74 views
0

我有一組複選框'框',現在我希望我的下拉列表基於通過從數據庫中檢索單擊的複選框來顯示名稱。基於複選框的顯示下拉列表

代碼:

$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); 
+2

http://whathaveyoutried.com? – Onheiron 2012-07-12 10:31:39

+0

你的代碼好友在哪裏 – 2012-07-12 10:32:43

+0

請寫一些代碼,然後發佈後的問題... – Jalpesh 2012-07-12 10:35:20

回答

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> 
+0

對我沒有用.. – Lissa 2012-07-12 10:49:35

相關問題