常州网络公司首页 >>> WEB编程 >> ASP

三联或四联下拉菜单程序代码

发布时间:2009-4-21 11:17:13   浏览次数:4479

JS代码部分
<script language="javascript">
function newXMLHttpRequest() {
var xmlreq = false;
if (window.XMLHttpRequest) {
xmlreq = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e1) {
try {
xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
}
}
}
return xmlreq;
}

function BuildSel(str,ObjectName)
{
 ObjectName.options.length=0;
    var arrstr = new Array("","");
 var stID = new Array();
 var st = new Array();
 arrstr = str.split("|||");
 ObjectName.options[ObjectName.options.length]=new Option("",0);
 if(arrstr.length>1)
 {
  stID=arrstr[0].split("||");
  st=arrstr[1].split("||");
  for(i=0;i<stID.length;i++)
  {
     ObjectName.options[ObjectName.options.length]=new Option(st[i],stID[i]);
  }
 }
}


function getSClassname(cid,obj)
{
 var oBao=new newXMLHttpRequest()
    oBao.open("GET","ajax.asp?active=getSClassname&cid="+cid,false);
    oBao.send(null);
 var reValue=unescape(oBao.responseText);
 
 BuildSel(reValue,obj)
}

function smClear()
{
 objn=document.getElementById("smallClassID2");
 objn1=document.getElementById("smallClassID3");
 objn.options.length=0;
 objn1.options.length=0;
}

</SCRIPT>


<select class=f11 name="bighy" size="1" onChange="getSClassname(this.value,document.getElementById('smallClassID'));smClear();">
<option value="0">==选择行业一级分类==</option>
<%
dim sql11,rs_class_1
sql11="select * from infoclass where preid=0 order by taxis asc"
set rs_class_1= Server.CreateObject("ADODB.Recordset")
rs_class_1.open sql11,conn,1,1
do while not rs_class_1.eof
%>
<option value="<%=rs_class_1("id")%>" <%if int(bighy)=int(rs_class_1("id")) then response.write "selected" end if%>><%=rs_class_1("classname")%></option>
<%
rs_class_1.movenext
loop
%>
</select>
    <select name="smallClassID" size="1" class=f11 id="smallClassID"  onChange="getSClassname(this.value,document.getElementById('smallClassID2'))">
        <option value="0">==选择行业二级分类==</option>
      </select>

    <select name="smallClassID2" size="1" class=f11 id="smallClassID2" onChange="getSClassname(this.value,document.getElementById('smallClassID3'))">
      <option value="0">==选择行业三级分类==</option>
    </select>
   
<select name="smallClassID3" size="1" class=f11 id="smallClassID3">
      <option value="0">==选择行业四级分类==</option>
     </select>

 


在ajax.asp文件里的代码:
if active="getSClassname" then
 dim cid
 cid=request("cid")
 call sql_xlxcn(cid)
 idstr=""
 namestr=""
 set c=conn.execute("select * from infoclass where preid="&cid&" order by taxis asc")
 do while not c.eof
  if idstr="" then
   idstr=c("id")
   namestr=c("classname")
  else
   idstr=idstr&"||"&c("id")
   namestr=namestr&"||"&c("classname")
  end if
 c.movenext
 loop
 c.close
 set c=nothing
 response.write escape(idstr&"|||"&namestr)
end if

好了,就这些代码。

上一条:ASP中的include文件导入的用法
下一条:CSS控制内容滚动条
首页 | 在线留言 | 网站地图

CopyRight ©2008-2014   糊涂蛋技术网    苏ICP备05013073号
站长:万创   QQ:54960248  E-mail:xlxcn#126.com