var District = $("#district"); var preProvince = $("#pre_province"); 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 = " "; var initCity = ""; var initDistrict = ""; return { Init: function () { var that = this; that._LoadOptions(jsonProvince, preProvince、province、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); province.change(); function () { city.change() ; }); province.change(); }, _LoadOptions: function (datapath, preobj, targetobj, parentobj, Comparelen, initoption) { $.get( datapath, function (r) { var t = ''; // t: html コンテナ var s; // s: 選択された識別子 var pre; // pre: 初期値 if (preobj === 未定義) { pre = 0; } else { pre = preobj.val( ); } for (var i = 0; i s = ''; if (comparelen === 0) { if (pre !== "" && pre !== 0 && r[i].code === pre) { s = ' selected="selected" '; pre = ''; } t = '' } 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].コード '>' r[i].name ' } }