Ajax+Struts+Hibernate实现级联下拉单
Ajax+Struts+Hibernate实现级联下拉单转自:http://www.blogjava.net/rain1102/articles/69348.html
-------------------------------------------------------------------
<div style="padding: 4px 5.4pt; width: 95%;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif<html>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <head>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <title>kind.html</title>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <script type="text/javascript" src="js/common.js"></script>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif <script type="text/javascript">...
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif function refreshModelList()...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var oneName=document.getElementById("kindone").value;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif if(oneName=="")...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif clearlist();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var url="kind.do?method=search&&kindid="+oneName;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif createXMLHttpRequest();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif xmlHttp.onreadystatechange=handleStateChange;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif xmlHttp.open("GET",url,true);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif xmlHttp.send(null);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif function handleStateChange()...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif if(xmlHttp.readyState==4)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif if(xmlHttp.status==200)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif setNames();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif function clearlist()...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var models=document.getElementById("kindtwo");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif while(models.childNodes.length>0)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif models.removeChild(models.childNodes[0]);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif function setNames()...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif clearlist();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var models=document.getElementById("kindtwo");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var xmlDoc=xmlHttp.responseXML;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var results=xmlDoc.getElementsByTagName("kind");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif var option=null;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif for(var i=0;i<results.length;i++)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif option=document.createElement("option");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif option.appendChild(document.createTextNode(results.firstChild.nodeValue));
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif models.appendChild(option);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif </script>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </head>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <body>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <h2>dynamicLists</h2>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <select id="kindone" onchange="refreshModelList();">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <option value="1">a</option>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <option value="2">b</option>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <option value="3">c</option>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <option value="4">d</option>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </select>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif <select id="kindtwo">
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </select>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif </body>
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif</html>
页:
[1]