日期:2014-05-17  浏览次数:20668 次

IE和Firefox,关于onchange()的问题!
function Change_Select(selectValue,target,str)
  {
  if(selectValue.value==-2){
  document.userForm("teamVO.tname").value="";
  selectValue.value=-1;
  document.userForm.submit();
  }else{
  var strUrl;
  //查询城市list
  if(target=='teamVO.cityId')
  {  
  strUrl="pubAction.do?oper=searchArea&areaVO.superId="+selectValue.value;
  }
  else
  {
  if(selectValue.value=="-1")
  document.userForm.elements(target).style.display ="none";
  else
  document.userForm.elements(target).style.display ="";
  strUrl="pubAction.do?oper=searchTeamType&teamTypeVO.superid="+selectValue.value;
  }
  if(window.XMLHttpRequest)
  {
  req=new XMLHttpRequest();
  }else if(window.ActiveXObject)
  {
  req=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if(req)
  {
  req.open("GET",strUrl,true);
  req.onreadystatechange=function()
  {
  if(req.readyState == 4)
  {
  if(req.status == 200)
  {  
  parseMessage(selectValue.value,target,str);
  }
  else
  {
  alert("Not able to retrieve description"+req.statusText);
  }
  }
  }
  req.send(null);
  }
  }
  }


<html:select name="userForm" property="teamVO.typeId" onchange="Change_Select(this,'teamVO.subTypeId','--请选择子类别--')" styleClass="input_re">
<html:option value="-1">--请选择类别--</html:option>
<html:option value="-2">全部</html:option>
<logic:present name="userForm" property="teamTypeVOList">
<html:optionsCollection name="userForm" property="teamTypeVOList" value="typeId" label="typeName"/>
</logic:present>
</html:select></td>
<td width="110">
<html:select name="userForm" property="teamVO.subTypeId" style="display:none" styleClass="input_re">
<html:option value="-1">--请选择子类别--</html:option>
</html:select>

选择一个下拉列表,调用onchange(),弹出一个子拉列表。
IE显示正确,Firefox不显示子下拉列表。

------解决方案--------------------
在FF下看这个document.userForm("teamVO.tname")弹出来是不是空对象