jsp二级联动选择框
来源:互联网 发布:全球网络哪里要翻墙 编辑:程序博客网 时间:2024/04/30 03:39
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@page import="com.jh.xh.hibernate.pojo.InfoTab"%>
<%@ page import="com.jh.xh.hibernate.business.LanMuService"%>
<%@ page import="com.jh.xh.hibernate.business.AreaService"%>
<%@ page import="com.jh.xh.hibernate.pojo.ParentAreaTab"%>
<%@ page import="com.jh.xh.hibernate.pojo.ChildAreaTab"%>
<%@ page import="com.jh.xh.hibernate.pojo.ParentLanmuTab"%>
<%@ page import="com.jh.xh.hibernate.pojo.ChildLanmuTab"%>
<%@ page import="java.util.Iterator"%>
<%
InfoTab info = (InfoTab) request.getAttribute("info");
System.out.println("父地区 id " + info.getParentAreaId());
System.out.println("子地区 id " + info.getChildAreaId());
System.out.println("父栏目 id " + info.getParentLanMuId());
System.out.println("子栏目 id " + info.getChildLanMuId());
System.out.println("hidden= " + info.getHidden());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>京华时报-京华网 分类信息</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
<link href="css/fenlei.css" rel="stylesheet" type="text/css" />
<script src="sortjavascript/Function.js"></script>
</head>
<body loadForm();">
<!--顶部开始-->
<!--顶部开始-->
<!--内容大框架-->
<c:import url="/head.jsp" charEncoding="GBK"></c:import>
<div style="width:940px;" class="he">
<div class="czhl_fenleisousuo he"></div>
<div class="czhl_fenleisousuo he">
<table width="100%" cellspacing="0">
<tr>
<td height="14" colspan="2"> 分类信息 >> 信息发布 </td>
</tr>
</table>
</div>
</div>
<div class="clear"></div>
<div class="he" style="width:940px; border:1px solid #ccc;">
<!--左边部分框架-->
<div class="czhl_liebiao">
<form name="theForm" id="theForm" method="post"
action="/ad/updateUserInfo.do?infoId=<%=info.getId()%>&hidden=<%=info.getHidden() %>"
onSubmit="return checkSubmit();">
<table width="630" align="center" cellspacing="7">
<tr>
<td><script language="JavaScript">
var onecount_area;
onecount_area=0;
subcat_area = new Array();
<%
int count_area = 0;
AreaService as=new AreaService();
Iterator it_area=as.findChildSelect();
while(it_area.hasNext())
{
ChildAreaTab ca=(ChildAreaTab)it_area.next();
%>
subcat_area[<%=count_area%>] = new Array("<%=ca.getName()%>","<%=ca.getParentId()%>","<%=ca.getId()%>");
<%
count_area = count_area + 1;
}
%>
onecount_area=<%=count_area%>;
function changelocation_area(id)
{
document.getElementById("childAreaId").length = 0;
var id=id;
var i;
document.getElementById("childAreaId").options[0] = new Option('二级分类','');
for (i=0;i < onecount_area; i++)
{
if (subcat_area[i][1] == id)
{
document.getElementById("childAreaId").options[document.getElementById("childAreaId").length] = new Option(subcat_area[i][0], subcat_area[i][2]);
}
}
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" align="right"> 地区: </td>
<td>
<select name="parentAreaId" id="parentAreaId"
onChange="changelocation_area(document.getElementById('parentAreaId').options[document.getElementById('parentAreaId').selectedIndex].value)"
size="1">
<option value="0" selected>一级地区</option>
<%
AreaService as1 = new AreaService();
Iterator it_area1 = as1.findParentSelect();
while (it_area1.hasNext()) {
ParentAreaTab pa = (ParentAreaTab) it_area1.next();
%>
<option value="<%=pa.getId()%>"
<%if(pa.getId().equals(info.getParentAreaId())){ out.println("selected");}%>
><%=pa.getName()%>
</option>
<%}%>
</select>
</td>
<td>
<select name="childAreaId" id="childAreaId">
<option value="0" selected> 二级地区 </option>
<%
AreaService _twoArea = new AreaService();
Iterator _childArea = _twoArea.findChildSelect(info.getParentLanMuId());
while (_childArea.hasNext()) {
ChildAreaTab _clll = (ChildAreaTab)_childArea.next();
System.out.println(_clll.getId());
%>
<option value="<%=_clll.getId()%>"
<%if(info.getChildAreaId().equals(_clll.getId())){ out.println("selected"); }%>
<%System.out.println("子地区 id= "+info.getChildAreaId());%>
><%=_clll.getName()%>
</option>
<%} %>
</select>
</td>
</tr>
<script LANGUAGE="JavaScript">
changelocation_area(document.getElementById("parentAreaId").options[document.getElementById("parentAreaId").selectedIndex].value);
</script>
</table></td>
<td>
<script language="JavaScript">
var onecount_lanmu;
onecount_lanmu=0;
subcat_lanmu = new Array();
<%
int count_lanmu = 0;
LanMuService parentLanMu=new LanMuService();
Iterator it_lanmu=parentLanMu.findChildSelect();
while(it_lanmu.hasNext())
{
ChildLanmuTab ca=(ChildLanmuTab)it_lanmu.next();
%>
subcat_lanmu[<%=count_lanmu%>] = new Array("<%=ca.getName()%>","<%=ca.getParentId()%>","<%=ca.getId()%>");
<%
count_lanmu = count_lanmu + 1;
}
%>
onecount_lanmu=<%=count_lanmu%>;
function changelocation_lanmu(id)
{
document.getElementById("childLanMuId").length = 0;
var id=id;
if(id==1)
{
document.getElementById("tt").innerHTML=document.getElementById("t01").innerHTML;
}
if(id==2)
{
document.getElementById("tt").innerHTML=document.getElementById("t02").innerHTML;
}
if(id==3)
{
document.getElementById("tt").innerHTML=document.getElementById("t03").innerHTML;
}
if(id==4)
{
document.getElementById("tt").innerHTML=document.getElementById("t02").innerHTML;
}
if(id==5)
{
document.getElementById("tt").innerHTML=document.getElementById("t02").innerHTML;
}
if(id==6)
{
document.getElementById("tt").innerHTML=document.getElementById("t05").innerHTML;
}
if(id==7)
{
document.getElementById("tt").innerHTML=document.getElementById("t02").innerHTML;
}
if(id==8)
{
document.getElementById("tt").innerHTML=document.getElementById("t04").innerHTML;
}
var i;
document.getElementById("childLanMuId").options[0] = new Option('二级分类','');
for (i=0;i < onecount_lanmu; i++)
{
if (subcat_lanmu[i][1] == id)
{
document.getElementById("childLanMuId").options[document.getElementById("childLanMuId").length] = new Option(subcat_lanmu[i][0], subcat_lanmu[i][2]);
}
}
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" align="right"> 分类: </td>
<td>
<select name="parentLanMuId" id="parentLanMuId"
onChange="changelocation_lanmu(document.getElementById('parentLanMuId').options[document.getElementById('parentLanMuId').selectedIndex].value)"
size="1">
<option value="0" selected>一级分类</option>
<%
LanMuService LanMu = new LanMuService();
Iterator it_lanmu1 = LanMu.findParentSelect();
while (it_lanmu1.hasNext()) {
ParentLanmuTab pl = (ParentLanmuTab) it_lanmu1.next();
%>
<option value="<%=pl.getId()%>"
<%if(pl.getId().equals(info.getParentLanMuId())){ out.println("selected"); }%>
><%=pl.getName()%>
</option>
<%
}
%>
</select>
</td>
<td>
<select name="childLanMuId" id="childLanMuId">
<option value="0" selected>二级分类</option>
<%
LanMuService _twoLanMu = new LanMuService();
Iterator _childLanMu = _twoLanMu.findChildSelect(info.getParentLanMuId());
while (_childLanMu.hasNext()) {
ChildLanmuTab _cll = (ChildLanmuTab)_childLanMu.next();
System.out.println(_cll.getId());
%>
<option value="<%=_cll.getId()%>"
<%if(info.getChildLanMuId().equals(_cll.getId())){ out.println("selected"); }%>
<%System.out.println("子栏目 id= "+info.getChildLanMuId());%>
><%=_cll.getName()%>
</option>
<%} %>
</select>
</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><c:import url="/sortform/modifyInfo.jsp" charEncoding="GBK"></c:import>
</td>
</tr>
</table>
</form>
</div>
<div class="clear"></div>
</div>
<!--页脚-->
<c:import url="/foot.jsp" charEncoding="GBK"></c:import>
<!--页面加载时 调用相应表单 -->
<script type="text/javascript">
function loadForm()
{
changelocation_lanmu(<%=info.getParentLanMuId() %>);
changelocation_area(<%=info.getParentAreaId() %>);
document.getElementById('childAreaId').value='<%=info.getChildAreaId() %>';
document.getElementById('childLanMuId').value='<%=info.getChildLanMuId() %>';
}
</script>
</body>
</html>
转载自http://maomao.51cto.com/blog/115985/22167
- jsp二级联动选择框
- 二级联动选择框
- jsp+js二级、三级联动选择框(05年版)
- JQuery实现二级 select框联动选择
- 二级联动城市选择
- jsp简单二级联动
- JSP二级联动菜单
- mobiscroll 二级联动,选择地址
- 二级联动 国省市选择
- JSP+JavaScript 二级联动 静态
- 一个日期选择的二级联动下拉框
- JS二级联动选择框动态创建和编辑实现
- ajax jsp二级联动下拉框 select框
- ajax jsp中二级下拉框联动 固定数据
- 下拉框二级联动
- js实现省市选择二级联动
- js+jsp+mysql二级联动菜单
- jsp+js实现的二级联动菜单
- 全程追踪入侵JSP网站
- 高级Linux操作系统的安全管理技巧
- jsp中群发邮件群发邮件
- 网络故障诊断和排除
- “冲击波”病毒的症状和解决方案
- jsp二级联动选择框
- 救回死机后Word未储存的资料
- 06年注册安全工程师试题
- 局域网网卡故障维修实例
- 女人如烟
- 病毒的分类
- 07年股民之歌 《死了都不卖》
- 在Servlet容器下建立一個基本Web應用程式該有的步驟
- c#2005