?? jsp頁面內(nèi)實(shí)現(xiàn)動(dòng)態(tài)下拉框!!.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0042)http://www.chinaunix.net/jh/26/106326.html -->
<!-- Generated by LibHtt 2003-10-22 22:45:31 Templet source: /data0/chinaunix.net/cgisrc/do_html/viewtopics_jh.html Warnings and errors: 0--><HTML><HEAD><TITLE>ChinaUnix.net - 請教:jsp頁面內(nèi)實(shí)現(xiàn)動(dòng)態(tài)下拉框!!</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META
content=Linux,Freebsd,Solaris,Sco,HP-UX,IBM-AIX,cisco,oracle,java,cgi,mysql,perl,Apache,proFTP,Sendmail,Qmail,DNS,Squid,Rsync,SSL
name=keywords>
<META content=中國UNIX技術(shù)社區(qū) name=description>
<STYLE type=text/css>BODY {
FONT: 12pt 宋體
}
TH {
FONT: 12pt 宋體
}
INPUT {
FONT: 12pt 宋體
}
SELECT {
FONT: 12pt 宋體
}
TEXTAREA {
FONT: 12pt 宋體
}
SELECT {
FONT: 12pt 宋體
}
checkbox {
FONT: 12pt 宋體
}
BODY {
FONT-SIZE: 12pt; FONT-FAMILY: "宋體", "serif"
}
TD {
FONT-SIZE: 12pt; FONT-FAMILY: "宋體", "serif"
}
P {
FONT-SIZE: 9pt; LINE-HEIGHT: 150%
}
</STYLE>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<DIV align=center>
<CENTER>
<TABLE cellSpacing=0 cellPadding=0 width="75%" border=0>
<TBODY>
<TR>
<TD height=45>
<P align=center><A href="http://www.chinaunix.net/"><IMG alt=ChinaUnix.net
src="jsp頁面內(nèi)實(shí)現(xiàn)動(dòng)態(tài)下拉框!!.files/logo.gif"
border=0></A> <B>CU-Java/JSP討論區(qū)精華帖 </B></P></TD></TR>
<TR>
<TR>
<TD vAlign=bottom align=left height=40><SMALL><A
href="http://www.chinaunix.net/">ChinaUnix.net</A> > <A
href="http://www.chinaunix.net/forum">論壇首頁</A> > <A
href="http://www.chinaunix.net/jh">精華首頁</A> > <A
href="http://www.chinaunix.net/jh/26">Java/JSP精華區(qū)</A> > 正文
</SMALL></TD></TR>
<TR>
<TD width="100%" bgColor=#49ade9 colSpan=5 height=2><IMG height=1
src="jsp頁面內(nèi)實(shí)現(xiàn)動(dòng)態(tài)下拉框!!.files/bline.gif" width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="75%" border=0>
<TBODY>
<TR>
<TD vAlign=center align=middle bgColor=#edf0f5 height=40><FONT
size=5><B>請教:jsp頁面內(nèi)實(shí)現(xiàn)動(dòng)態(tài)下拉框!!</B></FONT></TD></TR>
<TR>
<TD align=middle bgColor=#edf0f5 height=20><SMALL>http://www.chinaunix.net
作者:<A
href="http://www.chinaunix.net/forum/profile.php?mode=viewprofile&u=46833"
target=_blank>full</A> 發(fā)表于:2003-07-03
16:27:37</FONT></SMALL></TD></TR>
<TR>
<TD align=middle bgColor=#edf0f5>
<TABLE style="WORD-BREAK: break-all; BORDER-COLLAPSE: collapse"
cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
<TBODY>
<TR>
<TD vAlign=top><BR>我想在網(wǎng)頁中實(shí)現(xiàn)動(dòng)態(tài)下拉框,具體如下:
<BR><BR>有兩個(gè)下拉框A和B,選擇了A中的一項(xiàng)后,B自動(dòng)把根據(jù)A的選項(xiàng)[color=red:0adcd4a2c9]到數(shù)據(jù)庫中查詢的結(jié)果[/color:0adcd4a2c9]列出,供用戶選擇。
<BR><BR>這個(gè)問題困了我好久!目前我只能用兩個(gè)頁面來解決,即第一個(gè)頁面用表單提交A的選擇后,在第二個(gè)被請求的頁面內(nèi)顯示B下拉框,很繁瑣,各位高手能否提供好的解決方案,在此先謝了!!<BR><BR></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD align=middle><SMALL>【<A
href="http://www.chinaunix.net/forum/posting.php?mode=reply&t=106326">發(fā)表回復(fù)</A>】【<A
href="http://www.chinaunix.net/forum/viewtopic.php?t=106326">查看CU論壇原帖</A>】【<A
href="javascript:window.close()">關(guān)閉</A>】</SMALL> </TD></TR></TBODY></TABLE><!-----------回復(fù)----------->
<TABLE cellSpacing=0 cellPadding=0 width="75%" border=0>
<TBODY>
<TR>
<TD bgColor=#edf0f5>
<TABLE style="WORD-BREAK: break-all; BORDER-COLLAPSE: collapse"
cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<HR>
<SMALL> <A
href="http://www.chinaunix.net/forum/profile.php?mode=viewprofile&u=6872"
target=_blank>cinc</A> 回復(fù)于:2003-07-03 16:50:19</SMALL></TD></TR>
<TR>
<TD>比如該頁叫做 list.jsp
<BR><BR>開始 A 列表有東西, B 列表為空
<BR><BR>選中 A 的一項(xiàng)后 ,自動(dòng)轉(zhuǎn)向到這個(gè)頁面:
<BR><BR>list.jsp?listb_id=2
<BR><BR>list.jsp 根據(jù) listb_id 做查詢,把查詢出來的內(nèi)容列在列表 B 里
<BR><BR>具體傳什么參數(shù),你自己再根據(jù)你的應(yīng)用做決定。<BR><BR></TD></TR>
<TR>
<TD>
<HR>
<SMALL> <A
href="http://www.chinaunix.net/forum/profile.php?mode=viewprofile&u=31634"
target=_blank>rollingpig</A> 回復(fù)于:2003-07-03 16:51:37</SMALL></TD></TR>
<TR>
<TD>這是一個(gè)很經(jīng)典的問題 <BR><BR>基本解決方法有幾個(gè) <BR><BR>1。你現(xiàn)在用的方法: <BR>選擇了A,轉(zhuǎn)向頁面。
<BR>你可以繼續(xù)使用 <BR>但是可以考慮轉(zhuǎn)向頁面是本頁面,可能感覺上會(huì)好一點(diǎn)
<BR><BR><BR>2。直接把所有數(shù)據(jù)預(yù)先寫到頁面里的javascript的數(shù)組中,再在選擇A的時(shí)候改動(dòng)B
<BR>這種方法適用于數(shù)據(jù)量比較少的情況,如果數(shù)據(jù)量大了就不行了 <BR><BR>3。比較特殊的方法
<BR>在A選中之后,到服務(wù)器去下載一段動(dòng)態(tài)script,在script里改動(dòng)B的值<BR><BR></TD></TR>
<TR>
<TD>
<HR>
<SMALL> <A
href="http://www.chinaunix.net/forum/profile.php?mode=viewprofile&u=46833"
target=_blank>full</A> 回復(fù)于:2003-07-03 19:49:04</SMALL></TD></TR>
<TR>
<TD>我也考慮過轉(zhuǎn)向本頁面,可是有個(gè)問題:如果用表單的話,應(yīng)該要在該頁面上寫上諸如:
<BR><BR>String stepname = new String([color=red:78f242aacc]request[/color:78f242aacc].getParameter("stepname"))
<BR><BR>的語句,可是這樣的話,第一次打開此頁面是,會(huì)引發(fā)[color=red:78f242aacc]NullPointer[/color:78f242aacc]的例外!因?yàn)榈谝淮未蜷_時(shí),此頁面并沒被任何頁面請求,也就沒有request對象啊。
<BR><BR>那么應(yīng)該怎么處理呢?<BR><BR></TD></TR>
<TR>
<TD>
<HR>
<SMALL> <A
href="http://www.chinaunix.net/forum/profile.php?mode=viewprofile&u=31634"
target=_blank>rollingpig</A> 回復(fù)于:2003-07-03 19:51:27</SMALL></TD></TR>
<TR>
<TD>呵呵 <BR><BR>你判斷他 <BR>[code:1:ec21b7b8a5]
<BR>if(stepname ==null){ <BR>stepname="DEFAULT"; <BR>}
<BR><BR>[/code:1:ec21b7b8a5]
<BR><BR>DEFAULT改為你的A中的第一項(xiàng)!!<BR><BR></TD></TR>
<TR>
<TD>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -