常用js:
流程: 通過默認加載省數據,當改變省下拉框,將同時加載市的數據。
參考js代碼如下:
function loadCountry() {
$.AjaxRequest.request({
url: "nationInfo.list.action",
data: null,
success: function(data){
var select1 = $("#country_select_list");
select1.empty();
for(var i=0;i<data.dto.length;i++){
select1.append("<option value=\""+data.dto[i].nationCode+"\">"+data.dto[i].nationNameEN+"</option>");
}
}
});
}
// 加載信息
loadCountry();
$("#country_select_list").change(function(){
var nationCode = $(this).val();
$.AjaxRequest.request({
url: "nationInfo.agentIDBysNationID.list.action",
data: {agentId:nationCode},
success: function(data){
var select1 = $("#agent_select_list");
select1.empty();
for(var i=0;i<data.dto.length;i++){
select1.append("<option value=\""+data.dto[i].agentId+"\">"+data.dto[i].agentName+"</option>");
}
}
});
});
前臺可以是select 或者別的標籤。如果使用struts2特有標籤將是更方便。一個標籤相當兩個Ajax.
不常見的html 顯示格式:
常用的些正則現成的:
驗證IP地址: var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;