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

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

📁 一个连接数据库实现级联的代码
💻 HTM
📖 第 1 页 / 共 5 页
字号:
               <select style="WIDTH: 150px" id=fgs name="fgs" 
            onchange="changetext(document.test.fgs.options[document.test.fgs.selectedIndex].value)"> 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option value="" 
            selected&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;%<BR><BR>String str="select * from 
            fgs";<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
            <BR>ResultSet rs = 
            ExecuteWay.exeSqlQuery(str);//connbean是一个javabean,如果不会请不要问我,请去看看书。<BR>while(rs.next()){<BR>out.println("&lt;option 
            value='"+rs.getInt("id")+"'&gt;"+ 
            rs.getString("name")+"&lt;/option&gt;");<BR>&nbsp; &nbsp;}<BR>&nbsp; 
            &nbsp;rs.close();<BR>%&gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp; 
            &lt;!--<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="百色"&gt;百色<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="田阳"&gt;田阳<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="田东"&gt;田东<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="平果"&gt;平果<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="德保"&gt;德保<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="靖西"&gt;靖西<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="那坡"&gt;那坡<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="凌云"&gt;凌云<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="乐业"&gt;乐业<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="田林"&gt;田林<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="隆林"&gt;隆林<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="西林"&gt;西林<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;--&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/select&gt;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/td&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;tr&gt;<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; 
            &nbsp;&nbsp;&nbsp;&lt;!--<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;Input type="text" id=yddd 
            name="yddd"&nbsp;&nbsp;width="150px"&gt;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;--&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;select name="yddd" id="yddd" style="WIDTH: 
            150px"&gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value=""&gt;&lt;/option&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/select&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/td&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/tr&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;<BR>&nbsp; &nbsp;&nbsp;&nbsp;<BR>&nbsp; &nbsp; <BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;tr&gt;<BR>&nbsp; &nbsp;&nbsp;&nbsp;&lt;td 
            width="20%" align=right&gt;用电类型: &lt;/td&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;td width="20%" align=right&gt;<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;select style="WIDTH: 150px" 
            id=ydlx name="ydlx" &gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&lt;option value="" selected&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&lt;option value="普工"&gt;普工<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option value="生产"&gt;生产<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option value="商业"&gt;商业<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option value="营业"&gt;营业<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option value="变损"&gt;变损<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="工业"&gt;工业用电<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="生活"&gt;生活用电<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/select&gt;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/td&gt;<BR>&nbsp; &nbsp; &lt;/TR&gt;<BR>&nbsp; 
            &nbsp; &lt;tr&gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;td 
            width="20%" align=right&gt;月 &nbsp;&nbsp; 份: &lt;/td&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;td width="20%" align=right&gt;<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;select style="WIDTH: 150px" id=yf 
            name="yf" &gt;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;option 
            value="0" selected&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="1"&gt;1<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="2"&gt;2<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="3"&gt;3<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="4"&gt;4<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="5"&gt;5<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="6"&gt;6<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="7"&gt;7<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="8"&gt;8<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="9"&gt;9<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="10"&gt;10<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="11"&gt;11<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;option value="12"&gt;12<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/select&gt;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/td&gt;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;/tr&gt;<BR>&nbsp; &nbsp;&nbsp;&nbsp;&lt;TR&gt; 
            <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;td colSpan=2 
            align="center"&gt;<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;input type="submit" value="查询" 
            name=submit onClick="return Check(yf)"&gt; <BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;&lt;input type=reset value="重填" 
            name=reset&gt;&lt;/td&gt;<BR>&nbsp; &nbsp; &lt;/TR&gt;<BR>&nbsp; 
            &nbsp; &lt;/table&gt;<BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; 
            &lt;/form&gt;<BR>&nbsp; &nbsp;&nbsp;&nbsp;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;<BR>&nbsp; 
            &nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&lt;/body&gt;<BR>&lt;/html&gt;</DIV><BR><FONT 
            style="FONT: 12px Tahoma, Verdana; COLOR: #333333"></FONT></I></I></I></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=868358&amp;extra=&amp;page=1">引用</A> 
            <A onclick="fastreply('回复 #3 的帖子')" 
            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=pid868361></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#pid868361', '已经复制到剪贴板')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">#4</A></DIV>
            <DIV style="PADDING-TOP: 6px">发表于 2008-8-20 12:02 </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=868361"></A></DIV>
            <DIV class=t_msgfont id=message868361>页面代码如上 
            <BR><BR>运行的时候分公司那个下拉框可以从数据库取出数据了 <BR><BR>但是选择分公司的时候用电地点没有跟着出来,提示脚本错误 
            <BR><BR>错误提示如下 <BR>Line:2720 <BR>Char:1 <BR>Code:0 <BR>Error:缺少对象 
            <BR><BR>根本就没有2720这一行啊。 <BR><BR>大家帮我看看上面的JS哪里有错啊?</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=868361&amp;extra=&amp;page=1">引用</A> 
            <A onclick="fastreply('回复 #4 的帖子')" 
            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=pid868382></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#pid868382', '已经复制到剪贴板')" 
            href="http://tech.techweb.com.cn/viewthread.php?tid=247154###">#5</A></DIV>
            <DIV style="PADDING-TOP: 6px">发表于 2008-8-20 12:11 </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=868382"></A></DIV>
            <DIV class=t_msgfont id=message868382>不想写的那么麻烦 <BR>给你个思路吧 
            <BR>第一个下拉菜单你加上 onchang="didian();" <BR><BR>JScript code<BR>function 
            createXMLHttpRequest() {<BR>&nbsp; &nbsp; if (window.ActiveXObject) 
            {<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;xmlHttp = new 
            ActiveXObject("Microsoft.XMLHTTP");<BR>&nbsp; &nbsp; }<BR>&nbsp; 
            &nbsp; else if (window.XMLHttpRequest) {<BR>&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;&nbsp;xmlHttp = new XMLHttpRequest();<BR>&nbsp; &nbsp; 
            }<BR>}<BR>function didian() {<BR>&nbsp;&nbsp;var gongsi = 
            document.getElementById(第一个select的id).value;<BR>&nbsp;&nbsp;createXMLHttpRequest();<BR>&nbsp;&nbsp;xmlHttp.open("GET", 
            "后台servlet?gongsi=" + gongsi, 
            false);<BR>&nbsp;&nbsp;xmlHttp.send();<BR>&nbsp;&nbsp;var e = 
            xmlHttp.responseXML.getElementsByTagName("didian");<BR>&nbsp;&nbsp;var 
            c = 
            e[0].childNodes[0].firstChild.nodeValue;<BR>&nbsp;&nbsp;alert(c);//测试是不是你想要的值<BR>&nbsp;&nbsp;document.getElementById(第一个select的id).value 
            = c;//这句代码可能有问题&nbsp;&nbsp;<BR>}<BR><BR><BR><BR>后台代码: <BR><BR>Java 
            code<BR>StringBuffer results = new 
            StringBuffer("&lt;dd&gt;");<BR>response.setContentType("text/html;charset=UTF-8");<BR>String 
            gongsi = request.getParameter("gongsi");<BR>//连接数据库获取地点 
            didian<BR>results.append("&lt;didian&gt;&lt;di&gt;" + didian + 
            "&lt;/di&gt;&lt;/didian&gt;");<BR>results.append("&lt;/dd&gt;");<BR>&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;<BR>response.setContentType("text/xml");<BR>response.getWriter().write(results.toString());</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=868382&amp;extra=&amp;page=1">引用</A> 
            <A onclick="fastreply('回复 #5 的帖子')" 

⌨️ 快捷键说明

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