三级联动的编辑页面

在employee实体中保存的是proviceId,cityId,areaId。

 

 

应用s标签的编辑页面:

 

<SCRIPT type="text/javascript">
$(function(){
	$("#proId").change(function(){
		var proId = $("#proId").val();
		$("#cityId").empty();
		$("#areaId").empty();
		
		$.ajax({
			url:"empjson!querycity.action",
			type:"POST",
			dataType:"json",
			data:{"parentId":proId},
			success:function(listcity){
				for(var i=0;i<listcity.length;i++){
					$("#cityId").append("<option value='"+listcity[i].addressId+"'>"+listcity[i].addressName+"</option>");
				}
			},
			error:function(){alert("error");}
		
		
		});	
	});
	
	$("#cityId").change(function(){
		var cityId = $("#cityId").val();
		$("#areaId").empty();
			$.ajax({
				url:"empjson!queryarea.action",
				type:"POST",
				dataType:"json",
				data:{"cityId":cityId},
				success:function(listcity){
					for(var i=0;i<listcity.length;i++){
						$("#areaId").append("<option value='"+listcity[i].addressId+"'>"+listcity[i].addressName+"</option>");
					}
				
				},
				error:function(){alert("error");}
			
			});
	
	
	});


});


</SCRIPT>
  </head>
  
  <body>
<form action="emp!editSave.action" method="post">
<table>
	<tr>
		<td>empname:</td>
		<td><input type="text" name="employee.employeeName" value="${employee.employeeName}"/></td>
	</tr>
	<tr>
		<td>department:</td>
		<td>  	<s:select list="listdep" listKey="departmentId" listValue="departmentName" name="employee.department.departmentId"></s:select>
		</td>
	</tr>
	 <tr>
  	<td>department:</td>
  	<td>
  	<s:select list="listdep" listKey="departmentId" listValue="departmentName" name="employee.department.departmentId"></s:select>
  	</td>
  </tr>
  <tr>
  	<td>provice:</td>
  	<td><s:select id = "proId" list="listpro" listKey="addressId" listValue="addressName" name="employee.proviceId"></s:select></td>
  </tr>
  <tr>
  	<td>city:</td>
  	<td>
  	<s:select id = "cityId" list="listcity" listKey="addressId" listValue="addressName" name="employee.cityId"/>
  	</td>
  </tr>
  <tr>
  	<td>area:</td>
  	<td>
  		 <s:select id = "areaId" list="listarea" listKey="addressId" listValue="addressName" name="employee.areaId"/>
  		
  	</td>
  </tr>
	<tr><td><input type="submit" value="editSave"></td></tr>
</table>
</form>

 

在Action中,editPage的方法:

 

 

public String editPage(){

		employee = employeeService.queryById(id);
		listpro = employeeService.queryPro();
		listcity = employeeService.queryCity(employee.getProviceId());
		listarea = employeeService.queryArea(employee.getCityId());
		listdep = employeeService.queryDepList();
		return "editPage";
	}

 

在显示select下的option

var pro = $("#proId").find("option:selected").val();

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值