Javascript three-level linkage effect 2

Source: Internet
Author: User

Javascript three-level linkage effect 2
Var text = ""; for (I = 0; I <data. length; I ++) {text + = "<option value =" + I + "data-pId =" + data [I]. pId + ">" + data [I]. pName + "</option>" ;}$ (". shengf "). append (text); // step2: City var text2 = ""; $ (". shengf "). change (function () {text2 = "<option> select a city </option>"; $ (". city option "). remove (); $ (". zhanyd option "). remove (); $ (". zhanyd "). append ("<option> select a store </option>"); var cityid = $ (this ). val (); var shengfs; if (cityid. length <5) {shengfs = data [cityid]. cities; for (j = 0; j <shengfs. length; j ++) {text2 + = "<option value =" + j + "data-cId =" + shengfs [j]. cId + ">" + shengfs [j]. cName + "</option>" ;}// step3: store var text3 = ""; $ (". city "). change (function () {text3 = "<option> select a franchise store </option>"; $ (". zhanyd option "). remove (); var shengfid = $ (this ). val (); if (shengfid. length <5) {var zhanyds = shengfs [shengfid]. dealers; for (z = 0; z <zhanyds. length; z ++) {text3 + = "<option value =" + z + "data-dCode =" + zhanyds [z]. dCode + ">" + zhanyds [z]. dName + "</option>" ;}}$ (". zhanyd "). append (text3) ;};}$ (". city "). append (text2 );});

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.