php字符串双引号转义:在jsp中如何把文本框的值传到下拉列表框

来源:百度文库 编辑:中科新闻网 时间:2024/05/09 14:50:32

//HTML相关
<select name="select">
<option>值1</option>
<option>值2</option>
</select>
//可见下拉列表框中每一个值都是被嵌套在一对<option></option>中,OK,这样问题就该有点思路了。
//////////////////////////////////////////////////
<% String dbUrl = "jdbc:odbc:数据源名称";
String user = "";
String password = "";
String 字段值;
String 字段名;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection(dbUrl, user, password);
Statement s = c.createStatement();
ResultSet r=s.executeQuery("数据库查询语句,用于填充结果集");
while(r.next()) {//当结果集不为空
字段值=r.getString("数据库中的字段值");
字段名=r.getString("数据库中的字段名");

out.println("<option value=\""+字段值+"\">"+字段名+"</option>");}
%>
//就是这么简单的,呵呵~~