net 实现联级菜单
net 实现联级菜单
departmentName="科室名"
set departmentRs=server.CreateObject("adodb.recordset")
departmentSql="select * from [s_department] order by [id] asc"
departmentRs.open departmentSql,conn,1,1
do while not departmentRs.eof
departmentName=departmentName & "|" & departmentRs("department")
departmentID=departmentID & "|" & departmentRs("ID")
departmentRs.movenext
loop
set departmentRs=nothing
departmentName=departmentName & "|未分配科室"
departmentID=departmentID & "|0"
departmentName_array=split(departmentName,"|")
departmentID_array=split(departmentID,"|")
departmentName_count=ubound(departmentName_array)
i=0
response.Write("<script language='javascript'>" & chr(13))
response.Write("<!--//" & chr(13))
response.Write("var subcat = new Array(); " & chr(13))
for x=1 to departmentName_count step 1
set teacherRs=server.CreateObject("adodb.recordset")
teacherSql="select * from [t_account] where [department] =" & departmentID_array(x) & " and [WriteOff]='0' and [ID]<>1 order by [realname] asc"
teacherRs.open teacherSql,conn,1,1
do while not teacherRs.eof
response.Write("subcat[" & i & "] = new Array('" & departmentID_array(x) & "','" & teacherRs("realname") & " (" & teacherRs("username") & ")','" & teacherRs("ID") & "')" & chr(13))
teacherRs.movenext
i=i+1
loop
set teacherRs=nothing
next
response.Write("//-->" & chr(13))
response.Write("</script>" & chr(13))
复制内容到剪贴板代码:
<script language="JavaScript">
<!--
function changeselect1(locationid)
{
document.class_info2.teacher.length = 0; //初始化下拉列表 清空下拉数据
document.class_info2.teacher.options[0] = new Option('--- 请选择教师 ---',''); //给第一个值
for (i=0; i<subcat.length; i++)
{
if (subcat[i][0] == locationid)
{document.class_info2.teacher.options[document.class_info2.teacher.length] = new Option(subcat[i][1], subcat[i][2]);}
}
}
//-->
function check2()
{
if(document.class_info2.teacher.value == "")
{
window.alert("请选择教师 !!!");
return false ;
}
if(document.class_info2.subject.value == "")
{
window.alert("请选择课程 !!!");
return false ;
}
}
</script>
复制内容到剪贴板代码:
<!--// 表单名见上面JS代码 //-->
<select name="department" onChange="changeselect1(this.value)">
<option>--- 请选择科室 ---</option>
<% for k=1 to departmentName_count step 1 %>
<option value="<%=departmentID_array(k)%>"><%=departmentName_array(k)%></option>
<% next %>
</select>
<select name="teacher">
<option>--- 请选择教师 ---</option>
</select>
补充:asp.net教程,.Net开发