DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> JavaScript綜合知識 >> js獲取select標簽的值且兼容IE與firefox
js獲取select標簽的值且兼容IE與firefox
編輯:JavaScript綜合知識     

 本篇文章主要介紹了js獲取select標簽的值且兼容IE與firefox。需要的朋友可以過來參考下,希望對大家有所幫助

jsp代碼: 代碼如下: <form id="search">  <select id="jobSelect" style="width: 200px;" name="jobSelect">   <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 id="areaSelect" style="width: 200px;" name="areaSelect">   <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 class="send2" type="button" onclick="validate();return false" value="查詢" />  <span style="color: red;" mce_style="color: red;" id="requiredParam"></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
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved