- 论坛徽章:
- 0
|
请教:jsp页面内实现动态下拉框!!
may like this
- data.jsp
- <%@ page contentType="text/html; charset=GB2312" %>;
- <?xml version="1.0" encoding="GB2312" standalone="yes"?>;
- <dummy>;
- <%
- String id=request.getParameter("id");
- java.sql.ResultSet rs=null;
- rs=dbConn.exceute("select codes,name from aa where id = " + id);
- while(rs.next()){
- %>;
- <dummy2>;
- <codes>;
- <%=rs.getString(1)%>;
- </codes>;
- <name>;
- <%=rs.getString(2)%>;
- </name>;
- </dummy2>;
- <%}%>;
- </dummy>;
复制代码
- test.jsp
- <form name=test>;
- <select name=a onchange="change()">;
- <option value=1>;ONE</option>;
- <option value=2>;TWO</option>;
- <option value=3>;THREE</option>;
- <select>;
- <select name=b>;</select>;
- </form>;
- <XML id=xmldso>;</XML>;
- <script>;
- function change(){
- xmldso.async = false;
- xmldso.load("data.jsp?id="+document.test.a.value);
- with(document.test.b){
- xmldso.recordset.MoveFirst();
- for (var i=0;!xmldso.recordset.eof;i++){
- length=i+1;
- options[i].value=xmldso.recordset.fields(0).value;
- options[i].text=xmldso.recordset.fields(1).value;
- xmldso.recordset.MoveNext();
- }
- }
- }
- change();
- </script>;
复制代码 |
|