- 浏览: 54633 次
- 性别:
- 来自: 深圳
文章分类
最新评论
<%@ page contentType = "text/html; charset=GBK" import="java.util.*,com.wehave.hyerp.procurement.domain.Cgsqd"%>
<%@ taglib uri="struts-html" prefix="html" %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="struts-bean" prefix="bean" %>
<html>
<head>
<title> </title>
<link rel = "stylesheet" type = "text/css" href = "../css/olstyle.css">
<SCRIPT type="text/javascript">
var req;
window.onload=function(){
}
function Change_Select()
{
var zhi=document.getElementById('m_gykfwzlbb_lbbm').value;
var url="sqdSelect.go?method=getSkill&id="+zhi;
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}else{
if(window.XMLHttpRequest)
{
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{
req=new ActiveXObject("Microsoft.XMLHTTP");
}
if(req)
{
req.open("GET",url,true);
req.onreadystatechange=callback;
req.send(null);
}
}
}
function Change_Select2()
{
var zhi=document.getElementById('m_lbbm_se').value;
//alert(zhi.substring(0,2));
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}
if(zhi.substring(0,2)=="WY"){
var url="sqdSelect.go?method=getSkill2&id="+zhi;
if(window.XMLHttpRequest)
{
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{
req=new ActiveXObject("Microsoft.XMLHTTP");
}
if(req)
{
req.open("GET",url,true);
req.onreadystatechange=callback2;
req.send(null);
}
}else{
parent.topFram.location ="sqdSelectAll.go?method=getlistAll&id="+zhi;
}
}
function Change_Select3()
{
var zhi=document.getElementById('m_lbbm_th').value;
//alert(zhi.substring(0,2));
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}else{
parent.topFram.location ="sqdSelectAll.go?method=getlistAll2&id="+zhi;
}
}
function callback()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
parseMessage();
}else{
alert("Not able to retrieve description"+req.statusText);
}
}
}
function callback2()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
parseMessage2();
}else{
alert("Not able to retrieve description"+req.statusText);
}
}
}
function parseMessage()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('m_lbbm_se');
select_root.options.length=0;
for(var i=0;i<xSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
function parseMessage2()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('m_lbbm_th');
select_root.options.length=0;
for(var i=0;i<xSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
</SCRIPT>
</head>
<body bgcolor = "#C8D0D4">
<html:form action="/cgsqdNewAction.go">
<TABLE class = "cbToolbar" id = "idToolbar" cellpadding = '0' cellspacing = '0'>
<TR align = "left" valign = "top" >
<TD NOWRAP> 物质类别:
<html:select property="m_gykfwzlbb_lbbm" onchange="Change_Select()">
<html:option value="0">请选择</html:option>
<html:options collection="LbfList" property="m_gykfwzlbb_lbbm" labelProperty="m_gykfwzlbb_lbmc"/>
</html:select>
<html:select property="m_lbbm_se" styleId="m_lbbm_se" onchange="Change_Select2()">
<html:option value="0"> </html:option>
</html:select>
<html:select property="m_lbbm_th" styleId="m_lbbm_th" onchange="Change_Select3()">
<html:option value="0"> </html:option>
</html:select>
</TD>
</tr>
</table>
</html:form>
</body>
</html>
action中的代码:
/** *//**
*
* 查询物质编码类别列表操作(一级)
* */
public ActionForward doSelectWzlb(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
int updateSign=0;
try{
cgsqdService.updateCgsqwzhzb_sqsl();
updateSign=1;
}catch(Exception e){
e.printStackTrace();
updateSign=0;
}
if(updateSign==1){
List LbfList=cgsqdService.treeListWzlb2();
req.setAttribute("LbfList",LbfList);
return mapping.findForward("tools");
}else{
return null;
}
}else{
return mapping.findForward("failure");
}
}
/** *//**
*
* 查询物质编码类别列表操作(二级)
* */
public ActionForward doSelectWzlb1(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
int updateSign=0;
try{
cgsqdService.updateCgsqwzhzb_sqsl();
updateSign=1;
}catch(Exception e){
e.printStackTrace();
updateSign=0;
}
if(updateSign==1){
List LbfList=cgsqdService.treeListWzlb2();
req.setAttribute("LbfList",LbfList);
return mapping.findForward("tools1");
}else{
return null;
}
}else{
return mapping.findForward("failure");
}
}
/** *//**
*
* 查询物质编码类别列表操作(三级)
* */
public ActionForward getSkill(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
String id=req.getParameter("id");
res.setContentType("text/xml;charset=GBK");
res.setHeader("Cache-Control","no-cache");
String xml_start="<?xml version=\"1.0\" encoding=\"GBK\"?>";
xml_start+="<selects>";
String xml_end="</selects>";
String xml="<select><value>0</value><text>请选择</text></select>";
String m_lbbm_se="";
String m_lbmc_se="";
List LbfList=null;
if(id.equals("WY")){
LbfList=cgsqdService.treeListWzlb3_2(id);
}else{
LbfList=cgsqdService.treeListWzlb3_1(id);
}
Iterator it=LbfList.iterator();
while(it.hasNext()){
Cgsqd cgsqd=(Cgsqd)it.next();
m_lbbm_se=cgsqd.getM_gykfwzlbb_lbbm();
m_lbmc_se=cgsqd.getM_gykfwzlbb_lbmc();
xml +="<select><value>"+m_lbbm_se+"</value><text>"+m_lbmc_se+"</text></select>";
}
String last_xml=xml_start+xml+xml_end;
logger.debug("XML是:"+last_xml);
try {
res.getWriter().write(last_xml);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}else{
return null;
}
}(转)
<%@ taglib uri="struts-html" prefix="html" %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="struts-bean" prefix="bean" %>
<html>
<head>
<title> </title>
<link rel = "stylesheet" type = "text/css" href = "../css/olstyle.css">
<SCRIPT type="text/javascript">
var req;
window.onload=function(){
}
function Change_Select()
{
var zhi=document.getElementById('m_gykfwzlbb_lbbm').value;
var url="sqdSelect.go?method=getSkill&id="+zhi;
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}else{
if(window.XMLHttpRequest)
{
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{
req=new ActiveXObject("Microsoft.XMLHTTP");
}
if(req)
{
req.open("GET",url,true);
req.onreadystatechange=callback;
req.send(null);
}
}
}
function Change_Select2()
{
var zhi=document.getElementById('m_lbbm_se').value;
//alert(zhi.substring(0,2));
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}
if(zhi.substring(0,2)=="WY"){
var url="sqdSelect.go?method=getSkill2&id="+zhi;
if(window.XMLHttpRequest)
{
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{
req=new ActiveXObject("Microsoft.XMLHTTP");
}
if(req)
{
req.open("GET",url,true);
req.onreadystatechange=callback2;
req.send(null);
}
}else{
parent.topFram.location ="sqdSelectAll.go?method=getlistAll&id="+zhi;
}
}
function Change_Select3()
{
var zhi=document.getElementById('m_lbbm_th').value;
//alert(zhi.substring(0,2));
if(zhi=="0"){
alert("请选择您要察看的信息");
return;
}else{
parent.topFram.location ="sqdSelectAll.go?method=getlistAll2&id="+zhi;
}
}
function callback()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
parseMessage();
}else{
alert("Not able to retrieve description"+req.statusText);
}
}
}
function callback2()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
parseMessage2();
}else{
alert("Not able to retrieve description"+req.statusText);
}
}
}
function parseMessage()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('m_lbbm_se');
select_root.options.length=0;
for(var i=0;i<xSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
function parseMessage2()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('m_lbbm_th');
select_root.options.length=0;
for(var i=0;i<xSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
</SCRIPT>
</head>
<body bgcolor = "#C8D0D4">
<html:form action="/cgsqdNewAction.go">
<TABLE class = "cbToolbar" id = "idToolbar" cellpadding = '0' cellspacing = '0'>
<TR align = "left" valign = "top" >
<TD NOWRAP> 物质类别:
<html:select property="m_gykfwzlbb_lbbm" onchange="Change_Select()">
<html:option value="0">请选择</html:option>
<html:options collection="LbfList" property="m_gykfwzlbb_lbbm" labelProperty="m_gykfwzlbb_lbmc"/>
</html:select>
<html:select property="m_lbbm_se" styleId="m_lbbm_se" onchange="Change_Select2()">
<html:option value="0"> </html:option>
</html:select>
<html:select property="m_lbbm_th" styleId="m_lbbm_th" onchange="Change_Select3()">
<html:option value="0"> </html:option>
</html:select>
</TD>
</tr>
</table>
</html:form>
</body>
</html>
action中的代码:
/** *//**
*
* 查询物质编码类别列表操作(一级)
* */
public ActionForward doSelectWzlb(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
int updateSign=0;
try{
cgsqdService.updateCgsqwzhzb_sqsl();
updateSign=1;
}catch(Exception e){
e.printStackTrace();
updateSign=0;
}
if(updateSign==1){
List LbfList=cgsqdService.treeListWzlb2();
req.setAttribute("LbfList",LbfList);
return mapping.findForward("tools");
}else{
return null;
}
}else{
return mapping.findForward("failure");
}
}
/** *//**
*
* 查询物质编码类别列表操作(二级)
* */
public ActionForward doSelectWzlb1(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
int updateSign=0;
try{
cgsqdService.updateCgsqwzhzb_sqsl();
updateSign=1;
}catch(Exception e){
e.printStackTrace();
updateSign=0;
}
if(updateSign==1){
List LbfList=cgsqdService.treeListWzlb2();
req.setAttribute("LbfList",LbfList);
return mapping.findForward("tools1");
}else{
return null;
}
}else{
return mapping.findForward("failure");
}
}
/** *//**
*
* 查询物质编码类别列表操作(三级)
* */
public ActionForward getSkill(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) {
HttpSession session = req.getSession();
UserSession userSession =
(UserSession) session.getAttribute("userSession");
permission.setUserID(userSession.getUserId());
permission.setUserName(userSession.getUserName());
permission.setModuleName("m_cgsqd");
permission.setActionStr("'m_select'");
if(permissionService.checkUserPermission(permission)){
String id=req.getParameter("id");
res.setContentType("text/xml;charset=GBK");
res.setHeader("Cache-Control","no-cache");
String xml_start="<?xml version=\"1.0\" encoding=\"GBK\"?>";
xml_start+="<selects>";
String xml_end="</selects>";
String xml="<select><value>0</value><text>请选择</text></select>";
String m_lbbm_se="";
String m_lbmc_se="";
List LbfList=null;
if(id.equals("WY")){
LbfList=cgsqdService.treeListWzlb3_2(id);
}else{
LbfList=cgsqdService.treeListWzlb3_1(id);
}
Iterator it=LbfList.iterator();
while(it.hasNext()){
Cgsqd cgsqd=(Cgsqd)it.next();
m_lbbm_se=cgsqd.getM_gykfwzlbb_lbbm();
m_lbmc_se=cgsqd.getM_gykfwzlbb_lbmc();
xml +="<select><value>"+m_lbbm_se+"</value><text>"+m_lbmc_se+"</text></select>";
}
String last_xml=xml_start+xml+xml_end;
logger.debug("XML是:"+last_xml);
try {
res.getWriter().write(last_xml);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}else{
return null;
}
}(转)
相关推荐
一般的ajax实现的都是二级联动,所以我就找了好久的ajax实现三级联动,终于找到了.
利用vs2005+sql2005实现的省市县三级联动.
asp.net+用ajax实现三级联动实例!欢迎下载!
Ajax JavaWeb JS 三级联动 Ajax JavaWeb JS 三级联动 Ajax JavaWeb JS 三级联动
php+ajax实现三级联动(以省市县三级联动为例)
Ajax实现的三级联动下拉框
struts2+jsp+json+javascript实现的三级下拉菜单,没有service和dao层,数据是虚拟的。需要的欢迎下载。项目直接导入myeclipse就可以使用。访问路径localhost:8080/ajax_day02_hw/proviencecityarea.jsp
纯用javascript实现的ajax三级联动无刷新,数据传送采用json格式,开发平台采用vs2010 asp.net,压缩包含有sql脚本
js实现Ajax三级联动,省市区,实现异步刷新交互;首先选择省:黑龙江省 就会出现市:哈尔滨 大庆.....,选择哈尔滨,接下俩选择区,南岗区,香坊区
前段时间的项目做了个Ajax的三级联动的效果,现在传上来和大家分享
NULL 博文链接:https://huigege.iteye.com/blog/1852954
ajax实现3级联动例子(vs2003带数据库) 自己写的例子,共项给大家。
运用ajax实现三级联动,通过客户端拆分字符串,服务器返回自定义字符串,实现三级联动
使用javweb 和 ajax 相结合, 实现省市县三级联动
ajax三级联动,三级联动,联动,ajax,无刷新三级联动
基于Ajax的三级联动下拉菜单.rar基于Ajax的三级联动下拉菜单.rar基于Ajax的三级联动下拉菜单.rar基于Ajax的三级联动下拉菜单.rar基于Ajax的三级联动下拉菜单.rar基于Ajax的三级联动下拉菜单.rar