⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 求jsp+sql二级联动菜单! - 程序开发 - techweb-技术社区 - powered by techweb_com_cn!.htm

📁 一个连接数据库实现级联的代码
💻 HTM
📖 第 1 页 / 共 5 页
字号:
            style="FONT-SIZE: 0px; COLOR: #ffffff">tech.techweb.com.cn8C(?)~ 
            k%K$K&amp;I</FONT><BR>分公司名称和用电地点都是在一个表里面,表dfbzb,字段fgs,yddd; <FONT 
            style="FONT-SIZE: 0px; COLOR: #ffffff">TechWeb-技术社区:x,s'W7C0k9x#N</FONT><BR><BR><SPAN 
            style="DISPLAY: none">(L"d,m!V9m9o1D</SPAN>这个查询页面要怎么实现? <FONT 
            style="FONT-SIZE: 0px; COLOR: #ffffff">tech.techweb.com.cn!M;E6u"f*e"c</FONT><BR><BR><SPAN 
            style="DISPLAY: none">(~!r2?)|/n#}</SPAN>希望能给详细代码,小弟急用,谢谢!</B></DIV><BR><FONT 
            style="FONT: 12px Tahoma, Verdana; COLOR: #333333"></FONT></TD></TR>
        <TR>
          <TD align=right><A 
            href="http://tech.techweb.com.cn/post.php?action=reply&amp;fid=10&amp;tid=247154&amp;repquote=849220&amp;extra=&amp;page=1">引用</A> 
            <A onclick="fastreply('回复 #1 大腕 的帖子')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">回复</A> 
            <A onclick=scroll(0,0) 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###"><IMG 
            alt=顶部 
            src="求JSP+sql二级联动菜单! - 程序开发 - TechWeb-技术社区 - Powered by TechWeb_com_cn!.files/top.gif" 
            border=0></A> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<DIV class=spaceborder style="MARGIN-BOTTOM: 4px; WIDTH: 98%">
<TABLE class=t_row cellSpacing=0 cellPadding=6 width="100%" align=center>
  <TBODY>
  <TR style="HEIGHT: 100%">
    <TD class=t_user vAlign=top width="18%"><A name=pid868357></A><SPAN 
      class=bold>游客</SPAN> <SPAN class=smalltxt></SPAN><BR><SPAN 
      class=smalltxt>未注册 <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></SPAN></TD>
    <TD 
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" 
    vAlign=top width="82%">
      <TABLE class=t_msg cellSpacing=0 cellPadding=6 border=0>
        <TBODY>
        <TR>
          <TD>
            <DIV>
            <DIV class="right t_number"><A class=bold title=复制帖子链接到剪贴板 
            onclick="setcopy('http://tech.techweb.com.cn/viewthread.php?tid=247154&amp;page=1#pid868357', '已经复制到剪贴板')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">#2</A></DIV>
            <DIV style="PADDING-TOP: 6px">发表于 2008-8-20 12:01 </DIV></DIV></TD></TR>
        <TR>
          <TD class=line style="PADDING-TOP: 10px" vAlign=top height="100%">
            <DIV style="FLOAT: right" align=right><A title="评分 0" 
            href="http://tech.techweb.com.cn/misc.php?action=viewratings&amp;tid=247154&amp;pid=868357"></A></DIV>
            <DIV class=t_msgfont id=message868357>我刚写针对你要求写的,看看你就会了 
            <BR>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
            <BR>&lt;二&gt;一个 下拉 动态 读取 数据库 <BR>FOR: <BR>1. <BR>package Test; 
            <BR><BR>import java.sql.Connection; <BR>import java.sql.ResultSet; 
            <BR>import java.sql.Statement; <BR><BR>import 
            javax.servlet.http.HttpServletRequest; <BR>import 
            javax.servlet.jsp.JspWriter; <BR><BR>import DBConnect.DBConn; 
            <BR><BR>public class Bumen { <BR>public void 
            getBumen(HttpServletRequest request,JspWriter out) { <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Connection conn = null; <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Statement stmt = null; <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ResultSet rs = null; <BR><BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;try { <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;DBConn db = new DBConn(); <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;conn = 
            db.getConnection(); <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;stmt = conn.createStatement(); <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;String sql = "select 
            distinct bm_name from PJ_BM"; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;rs = stmt.executeQuery(sql); <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;String html =""; 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;while 
            (rs.next()) <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;{ <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp; String bm_name=rs.getString("bm_name"); 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp; out.print(" &lt;option&gt;"+bm_name+" &lt;/option&gt;"); 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;} <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;} catch (Exception e) { <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;e.getMessage(); 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;} finally { <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;try { <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
            rs.close(); <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp; stmt.close(); <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; conn.close(); 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;} catch 
            (Exception e) { <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp; e.getMessage(); <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;} <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;} <BR>&nbsp; &nbsp; } <BR>} <BR><BR>2.JSP 
            <BR>&lt;td&gt; <BR>&lt;select name="city"&gt; 
            <BR>&lt;option&gt;-请选择城市- &lt;/option&gt;&nbsp; &nbsp; <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;% <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Bumen bm=new Bumen(); <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;bm.getBumen(request,out); <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp; %&gt; <BR>&lt;/select&gt; <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/td&gt; 
            <BR>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</DIV><BR><FONT 
            style="FONT: 12px Tahoma, Verdana; COLOR: #333333"></FONT></TD></TR>
        <TR>
          <TD align=right><A 
            href="http://tech.techweb.com.cn/post.php?action=reply&amp;fid=10&amp;tid=247154&amp;repquote=868357&amp;extra=&amp;page=1">引用</A> 
            <A onclick="fastreply('回复 #2 的帖子')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">回复</A> 
            <A onclick=scroll(0,0) 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###"><IMG 
            alt=顶部 
            src="求JSP+sql二级联动菜单! - 程序开发 - TechWeb-技术社区 - Powered by TechWeb_com_cn!.files/top.gif" 
            border=0></A> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<DIV class=spaceborder style="MARGIN-BOTTOM: 4px; WIDTH: 98%">
<TABLE class=t_row cellSpacing=0 cellPadding=6 width="100%" align=center>
  <TBODY>
  <TR style="HEIGHT: 100%">
    <TD class=t_user vAlign=top width="18%"><A name=pid868358></A><SPAN 
      class=bold>游客</SPAN> <SPAN class=smalltxt></SPAN><BR><SPAN 
      class=smalltxt>未注册 <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></SPAN></TD>
    <TD 
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" 
    vAlign=top width="82%">
      <TABLE class=t_msg cellSpacing=0 cellPadding=6 border=0>
        <TBODY>
        <TR>
          <TD>
            <DIV>
            <DIV class="right t_number"><A class=bold title=复制帖子链接到剪贴板 
            onclick="setcopy('http://tech.techweb.com.cn/viewthread.php?tid=247154&amp;page=1#pid868358', '已经复制到剪贴板')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">#3</A></DIV>
            <DIV style="PADDING-TOP: 6px">发表于 2008-8-20 12:01 </DIV></DIV></TD></TR>
        <TR>
          <TD class=line style="PADDING-TOP: 10px" vAlign=top height="100%">
            <DIV style="FLOAT: right" align=right><A title="评分 0" 
            href="http://tech.techweb.com.cn/misc.php?action=viewratings&amp;tid=247154&amp;pid=868358"></A></DIV>
            <DIV class=t_msgfont id=message868358>Java code<BR>&lt;%@ page 
            language="java" import="java.util.*" 
            pageEncoding="gb2312"%&gt;<BR>&lt;%@ page 
            import="java.lang.*,java.sql.*,java.text.*,java.io.*"%&gt;<BR>&lt;jsp:useBean 
            scope="page" id="OpenDB" class="dfbz.OpenDB" 
            /&gt;<BR>&lt;jsp:useBean scope="page" id="ExecuteWay" 
            class="dfbz.ExecuteWay" /&gt;<BR>&lt;!DOCTYPE HTML PUBLIC 
            "-//W3C//DTD HTML 4.01 
            Transitional//EN"&gt;<BR>&lt;html&gt;<BR>&lt;head&gt;<BR>&nbsp; 
            &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;title&gt;电费报账明细查询&lt;/title&gt;<BR>&lt;style&gt;<BR>body{background:#E8FBFF;}<BR>&lt;/style&gt;<BR><BR><BR><BR>&lt;%<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;String str1="select * 
            from dzb";<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;ResultSet 
            rs2=ExecuteWay.exeSqlQuery(str1);<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;int&nbsp;&nbsp;count=0;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<BR>%&gt;<BR>&lt;script language= 
            "javascript "&gt; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var 
            scount1=0; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var stype=new 
            Array(); <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;% <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;while(rs2.next()){ <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;%&gt; <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;stype[&lt;%=count%&gt;]=new 
            Array("&lt;%=rs2.getString("yddd")%&gt;","&lt;%=rs2.getString("fid")%&gt;",&lt;%=rs2.getInt("id")%&gt;); 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;% <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;count++; <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;} <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;%&gt; 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;scount1=&lt;%=count%&gt;; 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;function changetext(fid) 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{ <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;document.test.yddd.length=0; <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var 
            fid=fid; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;var i; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;document.test.yddd.options[0]=new 
            Option('---请选择分公司---',''); <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for(i=0;i&lt;scount1;i++) <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{ 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(stype<I>[1]==fid) <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp; { <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
            document.test.yddd.options[document.test.yddd.length]=new 
            Option(stype<I>[0],stype<I>[2]); <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp; } <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; } <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; } 
            <BR>&lt;/script&gt; <BR><BR><BR><BR>&lt;script 
            language="javascript"&gt;<BR>function Check(yf){<BR>&nbsp;&nbsp;var 
            yf = document.test.yf.value;<BR>&nbsp;&nbsp;var test = 
            document.getElementById("test");<BR>&nbsp;&nbsp;if(yf == 
            0)<BR>&nbsp;&nbsp;{<BR>&nbsp; &nbsp; test.action = 
            "bhnresult2.jsp";<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp; 
            &nbsp; {<BR>&nbsp; &nbsp; test.action = "bhnresult1.jsp";<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;}<BR>}<BR>&lt;/script&gt;<BR><BR><BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;form&nbsp;&nbsp;method="post" name="test" 
            id="test" target=_self&gt;<BR>&lt;table 
            width="300"&nbsp;&nbsp;height="178" cellspacing="2" cellpadding="1" 
            align="center" border="0" id="mysjs"&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;TR&gt; <BR>&nbsp; &nbsp; <BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;td width="20%" align="right"&gt;分 
            公 司:&lt;/td&gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;td 
            width="20%" align=right&gt;<BR>&nbsp; &nbsp;&nbsp; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -