富贵资源网 Design By www.hznty.com
运行效果:
=================================================
部分代码:
=================================================
当然首先你数据库中要有这个table,不然你没有数据.....^_^
复制代码 代码如下:
<tr>
<td class="tr pr10 ">
所在地:
</td>
<td class="tl">
<input type="hidden" id="myProvince" value="${user.provinceId}"/>
<input type="hidden" id="myCity" value="${user.cityId}"/>
<input type="hidden" id="myRegion" value="${user.regionId}"/>
<select id="provinceSelect" name="user.provinceId">
<c:forEach items="${xzqhs}" var="xzqh">
<option value="${xzqh.provinceId}" ${user.regionId eq xzqh.provinceId?"selected='selected'":""}>${xzqh.province}</option>
</c:forEach>
</select>
<select id="citySelect" name="user.cityId">
</select>
<select id="regionSelect" name="user.regionId">
</select>
</td>
<td class="gray"></td>
</tr>
js代码:
复制代码 代码如下:
/**
* 加载市
*
*/
function loadCity() {
var provinceId = $("#provinceSelect option:selected").val();
if(provinceId == null || provinceId == ""){
//alert("找不到省");
}else{
$.post(rootPath+"/loadCity", {
"q" : provinceId
}, function(data, result) {
if(data == "noId"){
alert("请求错误");
}else if(data == "null"){
alert("系统找不到属于该省的市");
}else{
data = eval("{" + data + "}");
var citySelect = $("#citySelect");
var myCity = $("#myCity").val();
citySelect.html("");
for ( var i = 0; i < data.length; i++) {
if(myCity != null && myCity != "" && myCity > 0 && myCity == data[i].id){
citySelect.append("<option selected='selected' value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}else{
citySelect.append("<option value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}
}
loadRegion();
}
});
}
};
/**
* 加载区
*
*/
function loadRegion() {
var cityId = $("#citySelect option:selected").val();
if(cityId == null || cityId == "" || cityId < 1){
alert("找不到市");
}else{
$.post(rootPath+"/loadRegion", {
"q" : cityId
}, function(data, result) {
if(data == "noId"){
alert("请求错误");
}else if(data == "null"){
alert("系统找不到属于该市的区");
}else{
data = eval("{" + data + "}");
var regionSelect = $("#regionSelect");
var myRegion = $("#myRegion").val();
regionSelect.html("");
for ( var i = 0; i < data.length; i++) {
if(myRegion != null && myRegion != "" && myRegion > 0 && myRegion == data[i].id){
regionSelect.append("<option selected='selected' value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}else{
regionSelect.append("<option value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}
}
}
});
}
};
/**
* 省改变事件
*
*/
$("#provinceSelect").change(loadCity);
/**
* 市改变事件
*
*/
$("#citySelect").change(loadRegion);
$(function() {
loadCity();
});
后台方法:
复制代码 代码如下:
/**
* 加载城市数据
*
*/
public void loadCity() {
if (q == null || q.trim().equals("")) {
write("noId");
} else {
List<Xzqh> citys = xzqhService.queryCitys(q.trim());
if (citys == null || citys.size() < 1) {
write("null");
} else {
StringBuilder builder = new StringBuilder("[");
for (Xzqh city : citys) {
builder.append("{'id':'");
builder.append(city.getCityId());
builder.append("','name':'");
builder.append(city.getCity());
builder.append("'},");
}
if (builder.length() > 1)
builder.replace(builder.length() - 1, builder.length(), "]");
write(builder.toString());
}
}
}
/**
* 加载区数据
*
*/
public void loadRegion() {
if (q == null || q.trim().equals("")) {
write("noId");
} else {
List<Xzqh> citys = xzqhService.queryDistricts(q.trim());
if (citys == null || citys.size() < 1) {
write("null");
} else {
StringBuilder builder = new StringBuilder("[");
for (Xzqh district : citys) {
builder.append("{'id':'");
builder.append(district.getRegionId());
builder.append("','name':'");
builder.append(district.getRegion());
builder.append("'},");
}
if (builder.length() > 1)
builder.replace(builder.length() - 1, builder.length(), "]");
write(builder.toString());
}
}
}
=================================================
部分代码:
=================================================
当然首先你数据库中要有这个table,不然你没有数据.....^_^
复制代码 代码如下:
<tr>
<td class="tr pr10 ">
所在地:
</td>
<td class="tl">
<input type="hidden" id="myProvince" value="${user.provinceId}"/>
<input type="hidden" id="myCity" value="${user.cityId}"/>
<input type="hidden" id="myRegion" value="${user.regionId}"/>
<select id="provinceSelect" name="user.provinceId">
<c:forEach items="${xzqhs}" var="xzqh">
<option value="${xzqh.provinceId}" ${user.regionId eq xzqh.provinceId?"selected='selected'":""}>${xzqh.province}</option>
</c:forEach>
</select>
<select id="citySelect" name="user.cityId">
</select>
<select id="regionSelect" name="user.regionId">
</select>
</td>
<td class="gray"></td>
</tr>
js代码:
复制代码 代码如下:
/**
* 加载市
*
*/
function loadCity() {
var provinceId = $("#provinceSelect option:selected").val();
if(provinceId == null || provinceId == ""){
//alert("找不到省");
}else{
$.post(rootPath+"/loadCity", {
"q" : provinceId
}, function(data, result) {
if(data == "noId"){
alert("请求错误");
}else if(data == "null"){
alert("系统找不到属于该省的市");
}else{
data = eval("{" + data + "}");
var citySelect = $("#citySelect");
var myCity = $("#myCity").val();
citySelect.html("");
for ( var i = 0; i < data.length; i++) {
if(myCity != null && myCity != "" && myCity > 0 && myCity == data[i].id){
citySelect.append("<option selected='selected' value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}else{
citySelect.append("<option value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}
}
loadRegion();
}
});
}
};
/**
* 加载区
*
*/
function loadRegion() {
var cityId = $("#citySelect option:selected").val();
if(cityId == null || cityId == "" || cityId < 1){
alert("找不到市");
}else{
$.post(rootPath+"/loadRegion", {
"q" : cityId
}, function(data, result) {
if(data == "noId"){
alert("请求错误");
}else if(data == "null"){
alert("系统找不到属于该市的区");
}else{
data = eval("{" + data + "}");
var regionSelect = $("#regionSelect");
var myRegion = $("#myRegion").val();
regionSelect.html("");
for ( var i = 0; i < data.length; i++) {
if(myRegion != null && myRegion != "" && myRegion > 0 && myRegion == data[i].id){
regionSelect.append("<option selected='selected' value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}else{
regionSelect.append("<option value='" + data[i].id + "'>"
+ data[i].name + "</option>");
}
}
}
});
}
};
/**
* 省改变事件
*
*/
$("#provinceSelect").change(loadCity);
/**
* 市改变事件
*
*/
$("#citySelect").change(loadRegion);
$(function() {
loadCity();
});
后台方法:
复制代码 代码如下:
/**
* 加载城市数据
*
*/
public void loadCity() {
if (q == null || q.trim().equals("")) {
write("noId");
} else {
List<Xzqh> citys = xzqhService.queryCitys(q.trim());
if (citys == null || citys.size() < 1) {
write("null");
} else {
StringBuilder builder = new StringBuilder("[");
for (Xzqh city : citys) {
builder.append("{'id':'");
builder.append(city.getCityId());
builder.append("','name':'");
builder.append(city.getCity());
builder.append("'},");
}
if (builder.length() > 1)
builder.replace(builder.length() - 1, builder.length(), "]");
write(builder.toString());
}
}
}
/**
* 加载区数据
*
*/
public void loadRegion() {
if (q == null || q.trim().equals("")) {
write("noId");
} else {
List<Xzqh> citys = xzqhService.queryDistricts(q.trim());
if (citys == null || citys.size() < 1) {
write("null");
} else {
StringBuilder builder = new StringBuilder("[");
for (Xzqh district : citys) {
builder.append("{'id':'");
builder.append(district.getRegionId());
builder.append("','name':'");
builder.append(district.getRegion());
builder.append("'},");
}
if (builder.length() > 1)
builder.replace(builder.length() - 1, builder.length(), "]");
write(builder.toString());
}
}
}
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。