您好,我正在使用 php 和 javascript 并有代码,管理员可以在下拉框中选择一个名称,它会拉出与这些名称相关联的位置,这些是销售人员。好吧,它在 FF 和 Chrome 中运行良好,但在 IE 中,列表框只是空白。希望有人可以帮助我这里的老板使用IE
布伦特
下拉和列表代码
<label for="firstname"><?php echo ADD_EDIT_SALESREP;?><span class="required">*</span></label>
<select name="sales_rep" id="sales_rep" onChange="findLocation2(this.value)">
<option value="">Select</option>
<?php
$sqlQry1 = "SELECT * FROM ".TABLE_PREFIX."_employee WHERE status='t' AND is_Deleted='N' ORDER BY employee_Id";
$sql_Show1 = $DBObject->db_query($sqlQry1);
while($catArr = $DBObject->db_fetch_array($sql_Show1)){
?>
<div align="center"><br />
<option value="<?php echo $catArr['employee_Id'] ?>"><?php echo SafeOutput($catArr['first_Name']) ?> <?php echo SafeOutput($catArr['last_Name']) ?></option>
</div>
<?php
}
?>
</div>
</div>
</div>
<br />
<p>
</select>
<div id="salesrloc">
<select name="salesr_loc" id="salesr_loc" title="Sales Rep Loc" size="5" multiple="multiple">
<option value="">Select</option>
</select>
<br />
Javascript
<script language="javascript">
dv = document.createElement('div'); // create dynamically div tag
dv.setAttribute('id',"details");
function findLocation2(category)
{
dv.innerHTML='<div id="salesrloc" style="width:auto; height:200px;"><img src="image/loading.gif"></div> <br>';
var url11 = "salesrep2.php";
var qry11="?sales_rep=" + category ;
var result1='salesr_loc';
var ajaxRequest; // The variable that makes Ajax possible!
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){ //alert(ajaxRequest.responseText);
var a=ajaxRequest.responseText;
try{
document.getElementById('salesr_loc').innerHTML=ajaxRequest.responseText;
}catch(e){
dv.innerHTML=ajaxRequest.responseText;
}
}
}
ajaxRequest.open("POST", url11+qry11, true);
ajaxRequest.send(null);
} </script>
最后填充列表框 php
<?php
include("mastersecure.php");
$emp_id = $_GET['sales_rep'];
$qry= "select * FROM ".TABLE_PREFIX."_location ls, ".TABLE_PREFIX."_customer cs WHERE loc_Salesrep = ".$emp_id." AND ls.customer_Id = cs.customer_Id";
$res = $DBObject->db_query($qry);
?>
<body onLoad="document.getElementById('salesr_loc').focus();">
<select name="salesr_loc[]" id="salesr_loc" title="Sales Rep Loc" size="5" multiple="multiple">
<?php
while($row=$DBObject->db_fetch_array())
{
?>
<option value="<?=$row["location_Id"]?>"><?=$row["customer_Name"]?>, <?=$row["location_Name"]?></option>
<?php
}
?>
</select>
</body>