JS implementation of the Drop-down list of linkage (according to the selected text value, change another drop-down list of Chinese values (text))

Source: Internet
Author: User

To implement the linkage problem in the two Drop-down lists, change the value in another Drop-down list based on the value in the first Drop-down list, select the value of text, and change the value of text, such as the Drop-down list below, and choose the appropriate type of document according to nationality (if not Chinese nationality, the default choice passport)

<tr>
&LT;TD style= "Text-align:right" >
National &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cadastral
</td>
&LT;TD width= "20%" >
<asp:dropdownlist id= "DDLGJ" runat= "Server" height= "20px" width= "142px" runat= "Server" onchange= "Gethuzhao" () >
</asp:DropDownList>
</td>
&LT;TD style= "Text-align:right" width= "12%" >
Certificate type
<%--<asp:linkbutton id= "Lkbhospno" text= "one" forecolor= "Blue" runat= "server" font-underline= "True" Onclientclick= "Queryhispat ();" ></asp:LinkButton>--%><span>:</span>
</td>
&LT;TD width= "20%" >
<asp:dropdownlist id= "Ddlidcardtype" runat= "Server" height= "18px" width= "141px" class= "selected" >
</asp:DropDownList>
</td>
</tr>

JS Implementation code:

function   Gethuzhao ()
     {
        if ($ ("#ddlGJ"). Find ("option:selected"). Text ()!= "China") {
      $ ("#ddlIDCardType Option "). each (function () {
       if ($ (). Text () =" Passport ") {
         $ (This). attr ("selected", true);
       } 
      };
     }else {
      $ ("#ddlIDCardType option"). each (function () {
       if ($ (this). Text () = "resident identity card") {
         $ (This). attr ("selected", true);
       } 
      };
     }
    
    }

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.