Ajax实现三级联动下拉框

时间:2022-08-16 23:08:03
<% @ page contentType  =   " text/html; charset=GBK "    import = " java.util.*,com.wehave.hyerp.procurement.domain.Cgsqd " %>
Ajax实现三级联动下拉框
<% @ taglib uri = " struts-html "  prefix = " html "   %>
Ajax实现三级联动下拉框
<% @ taglib uri = " struts-logic "  prefix = " logic "   %>
Ajax实现三级联动下拉框
<% @ taglib uri = " struts-bean "  prefix = " bean "   %>
Ajax实现三级联动下拉框
< html >
Ajax实现三级联动下拉框    
< head >
Ajax实现三级联动下拉框        
< title >   </ title >
Ajax实现三级联动下拉框        
< link rel  =   " stylesheet "  type  =   " text/css "  href  =   " ../css/olstyle.css " >     
Ajax实现三级联动下拉框        
< SCRIPT type = " text/javascript " >
Ajax实现三级联动下拉框        var req;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        window.onload
= function() {
Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function Change_Select()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            var zhi
=document.getElementById('m_gykfwzlbb_lbbm').value;
Ajax实现三级联动下拉框            var url
="sqdSelect.go?method=getSkill&id="+zhi;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
if(zhi=="0"){
Ajax实现三级联动下拉框                alert(
"请选择您要察看的信息");
Ajax实现三级联动下拉框                   
return;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
else{
Ajax实现三级联动下拉框                
if(window.XMLHttpRequest)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req
=new XMLHttpRequest();
Ajax实现三级联动下拉框                }
else if(window.ActiveXObject)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req
=new ActiveXObject("Microsoft.XMLHTTP");
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框                
Ajax实现三级联动下拉框                
if(req)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req.open(
"GET",url,true);
Ajax实现三级联动下拉框                    req.onreadystatechange
=callback;
Ajax实现三级联动下拉框                    req.send(
null);
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function Change_Select2()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            var zhi
=document.getElementById('m_lbbm_se').value;
Ajax实现三级联动下拉框            
//alert(zhi.substring(0,2));
Ajax实现三级联动下拉框Ajax实现三级联动下拉框
            if(zhi=="0"){
Ajax实现三级联动下拉框                alert(
"请选择您要察看的信息");
Ajax实现三级联动下拉框                   
return;
Ajax实现三级联动下拉框               }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
if(zhi.substring(0,2)=="WY"){
Ajax实现三级联动下拉框                var url
="sqdSelect.go?method=getSkill2&id="+zhi;
Ajax实现三级联动下拉框                
if(window.XMLHttpRequest)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req
=new XMLHttpRequest();
Ajax实现三级联动下拉框                }
else if(window.ActiveXObject)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req
=new ActiveXObject("Microsoft.XMLHTTP");
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框                
Ajax实现三级联动下拉框                
if(req)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    req.open(
"GET",url,true);
Ajax实现三级联动下拉框                    req.onreadystatechange
=callback2;
Ajax实现三级联动下拉框                    req.send(
null);
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
else{
Ajax实现三级联动下拉框                parent.topFram.location 
="sqdSelectAll.go?method=getlistAll&id="+zhi;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function Change_Select3()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            var zhi
=document.getElementById('m_lbbm_th').value;
Ajax实现三级联动下拉框            
//alert(zhi.substring(0,2));
Ajax实现三级联动下拉框Ajax实现三级联动下拉框
            if(zhi=="0"){
Ajax实现三级联动下拉框                alert(
"请选择您要察看的信息");
Ajax实现三级联动下拉框                   
return;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框               }
else{
Ajax实现三级联动下拉框                parent.topFram.location 
="sqdSelectAll.go?method=getlistAll2&id="+zhi;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function callback()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            
if(req.readyState == 4)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
{
Ajax实现三级联动下拉框                
if(req.status == 200)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    parseMessage();
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                }
else{
Ajax实现三级联动下拉框                    alert(
"Not able to retrieve description"+req.statusText);
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function callback2()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            
if(req.readyState == 4)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
{
Ajax实现三级联动下拉框                
if(req.status == 200)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
{
Ajax实现三级联动下拉框                    parseMessage2();
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                }
else{
Ajax实现三级联动下拉框                    alert(
"Not able to retrieve description"+req.statusText);
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function parseMessage()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            var xmlDoc
=req.responseXML.documentElement;
Ajax实现三级联动下拉框            var xSel
=xmlDoc.getElementsByTagName('select');
Ajax实现三级联动下拉框            var select_root
=document.getElementById('m_lbbm_se');
Ajax实现三级联动下拉框            select_root.options.length
=0;
Ajax实现三级联动下拉框            
Ajax实现三级联动下拉框            
for(var i=0;i<xSel.length;i++)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
{
Ajax实现三级联动下拉框                var xValue
=xSel[i].childNodes[0].firstChild.nodeValue;
Ajax实现三级联动下拉框                var xText
=xSel[i].childNodes[1].firstChild.nodeValue;
Ajax实现三级联动下拉框                var option
=new Option(xText,xValue);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
try{
Ajax实现三级联动下拉框                    select_root.add(option);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                }
catch(e){
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        function parseMessage2()
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
{
Ajax实现三级联动下拉框            var xmlDoc
=req.responseXML.documentElement;
Ajax实现三级联动下拉框            var xSel
=xmlDoc.getElementsByTagName('select');
Ajax实现三级联动下拉框            var select_root
=document.getElementById('m_lbbm_th');
Ajax实现三级联动下拉框            select_root.options.length
=0;
Ajax实现三级联动下拉框            
Ajax实现三级联动下拉框            
for(var i=0;i<xSel.length;i++)
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
{
Ajax实现三级联动下拉框                var xValue
=xSel[i].childNodes[0].firstChild.nodeValue;
Ajax实现三级联动下拉框                var xText
=xSel[i].childNodes[1].firstChild.nodeValue;
Ajax实现三级联动下拉框                var option
=new Option(xText,xValue);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                
try{
Ajax实现三级联动下拉框                    select_root.add(option);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框                }
catch(e){
Ajax实现三级联动下拉框                }

Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框        
Ajax实现三级联动下拉框    
</ SCRIPT >
Ajax实现三级联动下拉框    
</ head >
Ajax实现三级联动下拉框
Ajax实现三级联动下拉框
< body bgcolor  =   " #C8D0D4 " >
Ajax实现三级联动下拉框    
< html:form action = " /cgsqdNewAction.go " >  
Ajax实现三级联动下拉框    
< TABLE  class   =   " cbToolbar "  id  =   " idToolbar "  cellpadding  =   ' 0 '  cellspacing  =   ' 0 ' >
Ajax实现三级联动下拉框        
< TR align  =   " left "  valign  =   " top "   >
Ajax实现三级联动下拉框            
< TD  NOWRAP >& nbsp;物质类别: & nbsp; & nbsp;
Ajax实现三级联动下拉框                
< html:select property = " m_gykfwzlbb_lbbm "  onchange = " Change_Select() " >
Ajax实现三级联动下拉框                    
< html:option value = " 0 " > 请选择 </ html:option >
Ajax实现三级联动下拉框                       
< html:options collection = " LbfList "  property = " m_gykfwzlbb_lbbm "  labelProperty = " m_gykfwzlbb_lbmc " />
Ajax实现三级联动下拉框                
</ html:select >   & nbsp;
Ajax实现三级联动下拉框                
< html:select property = " m_lbbm_se "  styleId = " m_lbbm_se "  onchange = " Change_Select2() " >
Ajax实现三级联动下拉框                    
< html:option value = " 0 " >& nbsp; & nbsp; & nbsp; </ html:option >
Ajax实现三级联动下拉框                
</ html:select >
Ajax实现三级联动下拉框                
< html:select property = " m_lbbm_th "  styleId = " m_lbbm_th "  onchange = " Change_Select3() " >
Ajax实现三级联动下拉框                    
< html:option value = " 0 " >& nbsp; & nbsp; & nbsp; </ html:option >
Ajax实现三级联动下拉框                
</ html:select >
Ajax实现三级联动下拉框                
Ajax实现三级联动下拉框            
</ TD >
Ajax实现三级联动下拉框            
Ajax实现三级联动下拉框        
</ tr >
Ajax实现三级联动下拉框    
</ table >
Ajax实现三级联动下拉框     
</ html:form >
Ajax实现三级联动下拉框
</ body >
Ajax实现三级联动下拉框
</ html >
Ajax实现三级联动下拉框

action中的代码:
Ajax实现三级联动下拉框Ajax实现三级联动下拉框/**
Ajax实现三级联动下拉框     * 
Ajax实现三级联动下拉框     * 查询物质编码类别列表操作(一级)
Ajax实现三级联动下拉框     * 
*/

Ajax实现三级联动下拉框    
public ActionForward doSelectWzlb(
Ajax实现三级联动下拉框            ActionMapping mapping,
Ajax实现三级联动下拉框            ActionForm form,
Ajax实现三级联动下拉框            HttpServletRequest req,
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            HttpServletResponse res) 
{
Ajax实现三级联动下拉框        HttpSession session 
= req.getSession();
Ajax实现三级联动下拉框        UserSession userSession 
=
Ajax实现三级联动下拉框            (UserSession) session.getAttribute(
"userSession");
Ajax实现三级联动下拉框        permission.setUserID(userSession.getUserId());
Ajax实现三级联动下拉框        permission.setUserName(userSession.getUserName());
Ajax实现三级联动下拉框        permission.setModuleName(
"m_cgsqd");
Ajax实现三级联动下拉框        permission.setActionStr(
"'m_select'");
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
if(permissionService.checkUserPermission(permission)){
Ajax实现三级联动下拉框            
int updateSign=0;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
try{
Ajax实现三级联动下拉框                cgsqdService.updateCgsqwzhzb_sqsl();
Ajax实现三级联动下拉框                updateSign
=1;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
catch(Exception e){
Ajax实现三级联动下拉框                e.printStackTrace();
Ajax实现三级联动下拉框                updateSign
=0;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
if(updateSign==1){
Ajax实现三级联动下拉框                List LbfList
=cgsqdService.treeListWzlb2();
Ajax实现三级联动下拉框                req.setAttribute(
"LbfList",LbfList);
Ajax实现三级联动下拉框                
return mapping.findForward("tools");
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
else{
Ajax实现三级联动下拉框                
return null;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框        }
else{
Ajax实现三级联动下拉框            
return mapping.findForward("failure");
Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框    }

Ajax实现三级联动下拉框    
Ajax实现三级联动下拉框Ajax实现三级联动下拉框    
/**
Ajax实现三级联动下拉框     * 
Ajax实现三级联动下拉框     * 查询物质编码类别列表操作(二级)
Ajax实现三级联动下拉框     * 
*/

Ajax实现三级联动下拉框    
public ActionForward doSelectWzlb1(
Ajax实现三级联动下拉框            ActionMapping mapping,
Ajax实现三级联动下拉框            ActionForm form,
Ajax实现三级联动下拉框            HttpServletRequest req,
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            HttpServletResponse res) 
{
Ajax实现三级联动下拉框        HttpSession session 
= req.getSession();
Ajax实现三级联动下拉框        UserSession userSession 
=
Ajax实现三级联动下拉框            (UserSession) session.getAttribute(
"userSession");
Ajax实现三级联动下拉框        permission.setUserID(userSession.getUserId());
Ajax实现三级联动下拉框        permission.setUserName(userSession.getUserName());
Ajax实现三级联动下拉框        permission.setModuleName(
"m_cgsqd");
Ajax实现三级联动下拉框        permission.setActionStr(
"'m_select'");
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
if(permissionService.checkUserPermission(permission)){
Ajax实现三级联动下拉框            
int updateSign=0;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
try{
Ajax实现三级联动下拉框                cgsqdService.updateCgsqwzhzb_sqsl();
Ajax实现三级联动下拉框                updateSign
=1;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
catch(Exception e){
Ajax实现三级联动下拉框                e.printStackTrace();
Ajax实现三级联动下拉框                updateSign
=0;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
if(updateSign==1){
Ajax实现三级联动下拉框                List LbfList
=cgsqdService.treeListWzlb2();
Ajax实现三级联动下拉框                req.setAttribute(
"LbfList",LbfList);
Ajax实现三级联动下拉框                
return mapping.findForward("tools1");
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
else{
Ajax实现三级联动下拉框                
return null;
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框Ajax实现三级联动下拉框        }
else{
Ajax实现三级联动下拉框            
return mapping.findForward("failure");
Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框    }

Ajax实现三级联动下拉框    
Ajax实现三级联动下拉框Ajax实现三级联动下拉框    
/**
Ajax实现三级联动下拉框     * 
Ajax实现三级联动下拉框     * 查询物质编码类别列表操作(三级)
Ajax实现三级联动下拉框     * 
*/

Ajax实现三级联动下拉框    
public ActionForward getSkill(
Ajax实现三级联动下拉框            ActionMapping mapping,
Ajax实现三级联动下拉框            ActionForm form,
Ajax实现三级联动下拉框            HttpServletRequest req,
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            HttpServletResponse res) 
{
Ajax实现三级联动下拉框        HttpSession session 
= req.getSession();
Ajax实现三级联动下拉框        UserSession userSession 
=
Ajax实现三级联动下拉框            (UserSession) session.getAttribute(
"userSession");
Ajax实现三级联动下拉框        permission.setUserID(userSession.getUserId());
Ajax实现三级联动下拉框        permission.setUserName(userSession.getUserName());
Ajax实现三级联动下拉框        permission.setModuleName(
"m_cgsqd");
Ajax实现三级联动下拉框        permission.setActionStr(
"'m_select'");
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        
if(permissionService.checkUserPermission(permission)){
Ajax实现三级联动下拉框            String id
=req.getParameter("id");
Ajax实现三级联动下拉框            
Ajax实现三级联动下拉框            res.setContentType(
"text/xml;charset=GBK");
Ajax实现三级联动下拉框            res.setHeader(
"Cache-Control","no-cache");
Ajax实现三级联动下拉框            String xml_start
="<?xml version=/"1.0/" encoding=/"GBK/"?>";
Ajax实现三级联动下拉框            xml_start
+="<selects>";
Ajax实现三级联动下拉框            String xml_end
="</selects>";
Ajax实现三级联动下拉框            String xml
="<select><value>0</value><text>请选择</text></select>";
Ajax实现三级联动下拉框            String m_lbbm_se
="";
Ajax实现三级联动下拉框            String m_lbmc_se
="";
Ajax实现三级联动下拉框            List LbfList
=null;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
if(id.equals("WY")){
Ajax实现三级联动下拉框                LbfList
=cgsqdService.treeListWzlb3_2(id);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
else{
Ajax实现三级联动下拉框                LbfList
=cgsqdService.treeListWzlb3_1(id);    
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框            Iterator it
=LbfList.iterator();
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
while(it.hasNext()){
Ajax实现三级联动下拉框                Cgsqd cgsqd
=(Cgsqd)it.next();
Ajax实现三级联动下拉框                m_lbbm_se
=cgsqd.getM_gykfwzlbb_lbbm();
Ajax实现三级联动下拉框                m_lbmc_se
=cgsqd.getM_gykfwzlbb_lbmc();
Ajax实现三级联动下拉框                xml 
+="<select><value>"+m_lbbm_se+"</value><text>"+m_lbmc_se+"</text></select>";
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框            String last_xml
=xml_start+xml+xml_end;
Ajax实现三级联动下拉框            logger.debug(
"XML是:"+last_xml);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            
try {
Ajax实现三级联动下拉框                res.getWriter().write(last_xml);
Ajax实现三级联动下拉框Ajax实现三级联动下拉框            }
 catch (IOException e) {
Ajax实现三级联动下拉框                e.printStackTrace();
Ajax实现三级联动下拉框            }

Ajax实现三级联动下拉框            
return null;
Ajax实现三级联动下拉框Ajax实现三级联动下拉框        }
else{
Ajax实现三级联动下拉框            
return null;
Ajax实现三级联动下拉框        }

Ajax实现三级联动下拉框    }