你是不知道怎么操作数据库吧?
假设A有两个字段:id name
<%
//建立到数据库的连接
%>
<select name="a" size="1" style="width:200px">
<option value="0"></option>
<%
sqlStr = "select * from A";
rs = st.executeQuery(sqlStr);
while ( rs.next() ) {
out.println("<option value='" + rs.getInt("id") + "'>" + rs.getString("name") + "</option>");
}
rs.close();
%>
</select>
假设A有两个字段:id name
<%
//建立到数据库的连接
%>
<select name="a" size="1" style="width:200px">
<option value="0"></option>
<%
sqlStr = "select * from A";
rs = st.executeQuery(sqlStr);
while ( rs.next() ) {
out.println("<option value='" + rs.getInt("id") + "'>" + rs.getString("name") + "</option>");
}
rs.close();
%>
</select>
解决方案 »
- 提高查询效率 针对sql语句 和 表的优化
- 关于用JSTL标签从JAVABEAN中读取值
- html 中有 readonly 属性 。我能不能在java程序中实现对页面这个属性的控制?
- 以数据库里查询出来的字段继续查询怎么做呀??
- 关于测试问题,请大家帮忙
- 求个转换字母的正则,在线等,得就结.
- 连数据库时,在sql语句中and or 之类的是大写还是小写?
- 我的JSP要和MYSQL相联,该怎么办??
- query.createSqlQuery 与query.createNativeQuery 的区别
- js正则表达式为什么写在两个/之间
- 呵呵,小问题《网页中的forbidden是怎么实现的?》 。建议就给分
- 如何将文件输入流转化为string?
<script language="javascript">
var fatherList=new Array(2);
var aListValue = new Array(2);
fatherList[0]="a";aListValue[0] = new Array("1","2");
fatherList[1]="d";aListValue[1] = new Array("456");var nCurIndex = null;function setupList()
{
if (nCurIndex != document.frmtest.name1.selectedIndex)
{var sValue = document.frmtest.name1.selectedIndex;var i;
//remove existing list
for (i=document.frmtest.name2.options.length-1; i >=0 ; i--)
document.frmtest.name2.options.remove(i);for (i=0; i < aListValue[sValue].length;i++)
{
var opt = new Option(aListValue[sValue][i],aListValue[sValue][i]);
document.frmtest.name2.options.add(opt);
} }}
</script><body onload="setupList()">
<form name="frmtest" action="" method="post">
List1:
<select name="name1" onchange="setupList()">
<script language="javascript">
for(i=0;i<fatherList.length;i++){
document.write("<option value=\"" + fatherList[i] + "\">" + fatherList[i] + "</option>");
}
</script>
</select>
<br>
List2:
<select name="name2">
</select>
<br>
</form>
</body>