var city = $("#city"); var District = $("#district"); var preProvince = $("#pre_province") var preCity = $("#pre_city"); var preDistrict = $("# pre_district"); var jsonProvince = "/content/json-array-of-province.js" var jsonCity = "/content/json-array-of -city.js"; var jsonDistrict = "/content/json-array-of-district.js"; var hasDistrict = true; var initProvince = "<옵션 값='0' >지방을 선택하세요 "; var initCity = ""; var initDistrict = "<옵션 값 ='0'>구 또는 카운티를 선택하세요 "; return { Init: function () { var that = this; that._LoadOptions(jsonProvince, preProvince, 지방, null, 0, initProvince); province.change(function () { that._LoadOptions(jsonCity, preCity, city, Province, 2, initCity); }); >if (hasDistrict) { city.change (function () { that._LoadOptions(jsonDistrict, preDistrict, District, city, 4, initDistrict); }); function () { city.change() ; }); } province.change() }, _LoadOptions: 함수(datapath, preobj, targetobj, parentobj, Comparelen, initoption) { $.get( datapath, function (r) { var t = ''; // t: html 컨테이너 var s; // s: 선택된 식별자 var pre; // pre: 초기 값 if (preobj === undefine) { pre = 0 } else { pre = preobj.val( ); } for (var i = 0; i < r.length; i ) { s = '' if (비교 === 0) { if (pre !== "" && pre !== 0 && r[i].code === pre) { s = ' selected="selected" ' pre = ''; } t = '<옵션 값= ' r[i].code s '>' r[i].name '' } else { var p = parentobj.val(); if (p.substring(0, Comparelen) === r[i].code.substring(0, Comparelen)) { if (pre !== " " && pre !== 0 && r[i] .code === pre) { s = ' selected="selected" '; pre = ''; } t = '<옵션 값=' r[i].code s '>' r[i].name '' } }