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 );});