js获取select标签的值且兼容IE与firefox

本篇文章主要介绍了js获取select标签的值且兼容IE与firefox。需要的朋友可以过来参考下,希望对大家有所帮助

jsp代码:

复制代码 代码如下:


<form>
 <select>
  <s:if test='jobSelect == null || jobSelect == ""'>
   <option selected="selected" value="-1">--依职类筛选--</option>
  </s:if>
  <s:else>
   <option value="-1">--依职类筛选--</option>
  </s:else>
  <s:iterator value="jobCat" status="s">
   <s:if test="jobSelect == catKey">
    <option value="<s:property value="catKey" />" selected="selected">
     <s:property value="catCnName" />
    </option>
   </s:if>
   <s:else>
    <option value="<s:property value="catKey" />">
     <s:property value="catCnName" />
    </option>
   </s:else>
  </s:iterator>
 </select> <br />
 <select>
  <s:if test='areaSelect == null || areaSelect == ""'>
   <option selected="selected" value="-1">--依地区筛选--</option>
  </s:if>
  <s:else>
   <option value="-1">--依地区筛选--</option>
  </s:else>
  <s:iterator value="workAreaCat" status="s">
   <s:if test="areaSelect == areaCat">
    <option value="<s:property value="areaCat" />" selected="selected">
     <s:property value="catCnName" />
    </option>
   </s:if>
   <s:else>
    <option value="<s:property value="areaCat" />">
     <s:property value="catCnName" />
    </option>
   </s:else>
  </s:iterator>
 </select>
 <input type="button" value="查询" />
 <span mce_style="color: red;"></span>
</form>


js代码:

复制代码 代码如下:


<mce:script type="text/javascript"><!--
 validate = function(){
  var jobSelect;
  var areaSelect;
  var search = document.getElementById("search");
  for(var i=0;i<search.jobSelect.length;i++){
   if(search.jobSelect[i].selected){
    jobSelect = search.jobSelect[i].value;
   }
  }
  for(var i=0;i<search.areaSelect.length;i++){
   if(search.areaSelect[i].selected){
    areaSelect = search.areaSelect[i].value;
   }
  }
  if(jobSelect == -1 && areaSelect == -1){
   document.getElementById('requiredParam').innerHTML = '请设定筛选条件后查询';
   return;
  }
  var param = {
         target : '../Index/JobFrame.action',
         method : 'post',
         form   : 'search',
         div    : 'box'
     }
     var as = new AjaxSender(param);
     as.send()
 }
// --></mce:script

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwzws.html