(function($){ $.fn.areapicker = function (){ var _this = $(this); var _aCode = $(this).attr('data-areaCode'); var _nCode = $(this).attr('data-nationCode'); var _cCode = $(this).attr('data-cityCode'); var _submit = $(this).attr('data-submit'); var _formname = $(this).attr('data-formname'); var _cityname_yn = $(this).attr('data-cityname-yn'); var _cityname_required = $(this).attr('data-cityname-required'); var _print = $(this).attr('data-print'); $.get( '/run.html', '&c=good&f=getAreaCodes&areaCode='+_aCode, function (data){ var html = "
"+data+"
"; html += "
"; html += "
"; _this.append(html); } ); if(_aCode){ setTimeout(function(){ $.get( '/run.html', '&c=good&f=getNationCodes&areaCode='+_aCode+'&nationCode='+_nCode, function (data){ $('#nation-code-list').append(data); } ); }, 300); if(_nCode){ setTimeout(function(){ $.get( '/run.html', '&c=good&f=getCityCodes&areaCode='+_aCode+'&nationCode='+_nCode+'&cityCode='+_cCode, function (data){ $('#city-code-list').append(data); if(_cityname_yn == 'N') $('#city-name').removeAttr('required').hide(); else { if(_cityname_required == 'N') $('#city-name').removeAttr('required').show(); else $('#city-name').removeAttr('required').show(); //else $('#city-name').attr('required').show(); } } ); }, 500); } } $(document).on('change', '#area-code, #nation-code, #city-code', function(){ if($('#city-code').val() != '') $('#city-name').removeAttr('required').hide(); else $('#city-name').removeAttr('required', '').show(); //else $('#city-name').attr('required', '').show(); var _this_id = $(this).attr('id'); var _submit_id = _this_id.substr(0, _this_id.indexOf('-')); if(_submit && _submit.indexOf(_submit_id) >= 0){ eval(_formname+'.submit()'); } }); } }) (jQuery)