JS gets the value of the Select tag and is compatible with IE and Firefox

Source: Internet
Author: User

  This article mainly introduces JS to obtain the value of the select tag and compatible with IE and Firefox. Need friends can come to the reference, I hope to help you.

JSP code: Code as follows: <form id= "Search" >  <select id= "jobselect" style= "width:200px;" Name= "Jobselect" >   <s:if test= ' jobselect = null | | Jobselect = "" ' >    <option selected= "selected" value= "-1" >--according to category--</option>   &LT;/S: if>   <s:else>    <option value= "-1" >--selected by category--</option>   </s:else>   <s:iterator value= "Jobcat" status= "S" >    <s:if test= "jobselect = Catkey" >     &L T;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" >--by region--</option>   &LT;/S :if>   <s:else>    <option value= "-1" >--Filter by Region--</option>   </s:else> & nbsp <s:iterator value= "Workareacat" status= "S" >    <s:if test= "areaselect = Areacat" >     & Lt;option value= "<s:property value=" Areacat "/>" selected= "selected" >      <s:property Value= "Catcnname"/>     </option>    </s:if>    <s:else>   & nbsp <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=" query "/>  <span style=" color:red; "mce_style=" color:red "id=" Requiredparam > </form>   JS code:   Code as follows: <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;   &NBSP}  }   for (Var i=0;i<search.areaselect.length;i++) {   if (search.areaselect[i). Selected) {    Areaselect = Search.areaselect[i].value    }  }   if (Jobselect = 1 && Amp Areaselect = = 1) {   document.getelementbyid (' Requiredparam '). InnerHTML = ' Please set filter criteria after query ';    return ;  }   var param = {         target: ' ... /index/jobframe.action ',          method: 'Post '          form  : ' Search ',          div   &nbsp: ' Box '     &NBSP}      var as = new Ajaxsender (param);      as.send ()  }//--></mce:script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.