html判断国家,对261个国家地区快速查找抉择
對261個國家地區快速查找選擇
實現的效果如下
當輸入小寫字母“z”的時候,刷出所有以z開頭的國家
當輸入漢字“美”的時候,刷出以美字開頭的國家
1、使用java,SSH,Easyui
2、數據庫設計,code:國家英語簡寫,note:中文注釋,pycode:中文拼音縮寫,english:英文名稱
其中pycode全部為小寫,note為中文名稱,其余字段全部是大寫
3、html代碼
國籍:4、js代碼
$(function(){
$('#country').combobox({//國家代碼初始化
valueField:'english',
textField:'note',
url:'json/country.json',
cache: false,
//panelHeight: 'auto',//自動高度適合
onChange: function(newValue,oldValue){
countrySearch(newValue);
}
});
});
function countrySearch(newValue){//國家信息更改
//判斷漢字 (/[\u4e00-\u9fa5]+/).test(newValue))
if((/[a-z]+/).test(newValue)||(/[\u4e00-\u9fa5]+/).test(newValue)){
$('#country').combobox({//國家代碼初始化
valueField:'english',
textField:'note',
url:'apply/countryCombobox_combobox.action?values='+encodeURI(encodeURI(newValue)),
cache: false
// panelHeight: 'auto'//自動高度適合
});
}
}
5、Action代碼
//模糊查詢國家代碼表
public String countryCombobox() throws Exception{
log.info("=====下拉框查詢國家代碼========");
values=URLDecoder.decode(values,"UTF-8");
String fields;
if(values.getBytes().length==values.length()){//如果相等 輸入的就不是漢字
log.info("pycode");
fields="pycode";
}else{//如果不相等 輸入的就是漢字
log.info("note");
fields="note";
}
List list=comboboxService.findCountry(fields, values);
this.jsonUtil(list);
return null;
}
6、接口
//查詢國家代碼表
public List findCountry(String fileds,String values) throws Exception;
7、接口實現類
//查詢國家代碼表
public List findCountry(String fields,String values) throws Exception{
Criteria criteria=this.sessionFactory.getCurrentSession().createCriteria(CcountryTbl.class);
//當屬性和值都不為空的時候,進行模糊查詢
if(StringUtils.isNotBlank(fields)&&StringUtils.isNotBlank(values)){
criteria.add(Restrictions.like(fields, values+"%"));
}
return criteria.list();
}
總結
以上是生活随笔為你收集整理的html判断国家,对261个国家地区快速查找抉择的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: intel 性能监控计数器PMC寄存器详
- 下一篇: 机械图纸英文标识诠释