Four-level link menu [Jsp+microsoft SQL Server]

Source: Internet
Author: User
Tags eval microsoft sql server stmt
js|server| Menu <%@ page contenttype= "text/html;charset=gb2312"%>
<%@ page import= "java.sql.*"%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Four-level link menu </title>
<body>
<form name= "frm" >
<select name=yijilei onchange= "Mulselect (3)" ></select>
<select name=erjilei onchange= "Mulselect (2)" ></select>
<select name=sanjilei onchange= "Mulselect (1)" ></select>
<select name=sijilei></select>
</form>
<script>
var arrsel=["Yijilei", "Erjilei", "Sanjilei", "Sijilei"]
Arrdata=[];
<%class.forname ("Com.microsoft.jdbc.sqlserver.SQLServerDriver"). newinstance ();

String url= "Jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs";

Pubs for your database of

String user= "SA";

String password= "SA";

Connection conn= drivermanager.getconnection (Url,user,password);

Statement stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable);

String sql= "SELECT * from news_lb";

ResultSet rs=stmt.executequery (SQL);

while (Rs.next ()) {%>
arrdata[arrdata.length]=["<%=rs.getstring (" News_lb_name ")%>", "<%=rs.getstring (" news_lb_e ")%>", " <%=rs.getstring ("News2")%> "," <%=rs.getstring ("News3")%> "]
<%}%>
<%rs.close ();
Stmt.close ();
Conn.close ();
%>
</script>
<script>
function Mulselect (num) {
var i,j,arrtemp=[];
for (i=0;i<num;i++) arrtemp[i]=eval ("Document.frm.") +arrsel[i]). Value
if (num<arrsel.length)
With (eval ("document.frm.") +arrsel[num])) {
Length=0
for (i=0;i<arrdata.length;i++) {
var find=false
for (j=0;j<num;j++) if (arrtemp[j]!=arrdata[i][j]) break;
if (j!=num) continue;
for (m=0;m<options.length;m++) if (Options[m].text==arrdata[i][num]) find=true
if (length==0| |! Find) {
Options[options.length]=new Option (Arrdata[i][num],arrdata[i][num])
}
}
Mulselect ((num+1))
}
}
Mulselect (0)
</script>
</body>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.