jquery 实现省市二级联动
2012-02-27 20:30
429 查看
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'example1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#province").change(function(){
$("#province option").each(function(i){
if($(this).attr("selected"))//如果被选中
{
//隐藏city
$(".city").hide();
//选取下表为i的city,然后显示出来
$(".city").eq(i-1).show();
}
});
});
$("#province").change();
});
</script>
</head>
<body>
<select id="province">
<option>---请选择省份---</option>
<option>北京</option>
<option>河北</option>
<option>山东</option>
</select>
<select class="city">
<option>东城</option>
<option>西城</option>
<option>海淀</option>
</select>
<select class="city">
<option>廊坊</option>
<option>保定</option>
<option>石家庄</option>
</select>
<select class="city">
<option>济南</option>
<option>烟台</option>
<option>青岛</option>
</select>
</body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'example1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#province").change(function(){
$("#province option").each(function(i){
if($(this).attr("selected"))//如果被选中
{
//隐藏city
$(".city").hide();
//选取下表为i的city,然后显示出来
$(".city").eq(i-1).show();
}
});
});
$("#province").change();
});
</script>
</head>
<body>
<select id="province">
<option>---请选择省份---</option>
<option>北京</option>
<option>河北</option>
<option>山东</option>
</select>
<select class="city">
<option>东城</option>
<option>西城</option>
<option>海淀</option>
</select>
<select class="city">
<option>廊坊</option>
<option>保定</option>
<option>石家庄</option>
</select>
<select class="city">
<option>济南</option>
<option>烟台</option>
<option>青岛</option>
</select>
</body>
</html>
相关文章推荐
- Jquery实现省市二级三级联动Json
- jQuery实现下拉框省市联动,二级联动
- 用jquery+Asp.Net实现省市二级联动
- 用jquery+Asp.Net实现省市二级联动
- jquery实现省市二级联动
- jquery+json+struts实现省市二级联动
- jQuery+php+mysql,轻松实现ajax无刷新省市二级联动
- jQuery判断用户名并实现省市的二级联动
- Struts2+jQuery+ajax+mySql实现省市二级联动
- 基于jquery实现省市联动效果
- Vue配合iView实现省市二级联动的示例代码
- jquery使用jquerydoubleselectmin.js实现二级菜单联动
- JQuery技术初探之二级联动的设计与实现
- JQuery实现的二级联动菜单
- jQuery + json 实现省市区三级联动
- JS实现的省市二级联动的脚本
- js实现的全国省市二级联动下拉选择菜单完整实例
- JQuery_用ajax实现二级联动
- JQuery实现添加删除数据全选反选隔行变色二级联动
- jquery读取xml文件实现省市县三级联动的方法