高手帮帮我!!!如何把选中的列表框中的数据存到数据库中????急急急!!! 在form里提交后,就可以用request取到值了啊,然后再往数据库里写! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在form里提交后,就可以用request取到值了啊,然后再往数据库里写! String year=request.getParameter("year");String month =request.getParameter("month");String day=request.getParameter("day"); 你的列表框是分开的吧,我指的是年,月,日分别由三个框那就把你的年月日的值取得,然后拼成yyyy/mm/dd的形式存就可以了 String stryear=requset.getParameter("year");Connection con;Statement sql;ResultSet rs;try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException event){}try{ con=DriverManager.getConnection("jdbc:odbc:数据源"); sql=con.createStatement(); String condition="insert into 表名 values"+"("+"'"+stryear+"')"; sql.executeUpdate(condition); con.close();} catch(SQLException e){} 你的列表框是多选的吗? <select name="mulSelect" size="1" multiple> <option value="....">.... <option value="....">.... <option value="....">.... <option value="....">.... .... </select>提交后取值:String[] strArray = request.getParameterValues("mulSelect");if(strArray!=null && strArray.length>1){ for(int i=0;i<strArray.length;i++){ //生成SQL语句; }}//执行数据库数据插入语句。 <select><option value="2001">2001</option></select>标签出怎墨写???我照 lynx1111(任我行)sgdb(神天月晓) 的话试了下返回null 另外; 从数据库中调用数据,如何在列表框中显示????请高手赐教 !!!! 我的列表框非多选。往数据库中写我回的,现在是我不知道如何从列表框中取到值, 以及如何把值显示在列表矿中?烦请各位大侠帮我一把!!!!!!!!!!!!!!!!!!!!!!!!!!照lynx1111(任我行)sgdb(神天月晓)那样做,select><option 标签处该怎么写?? <form method="POST" action="--WEBBOT-SELF--"> year: <select size="1" name="D1"> <option value="1999">1999年</option> <option value="2000">2000年</option> </select>month: <select size="1" name="D2"> <option value="1">1月</option> <option value="2">2月</option> <option value="3">3月</option> </select>date:<select size="1" name="D3"> <option value="1">1日</option> <option value="2">2日</option> <option value="3">3日</option> </select><input type="submit" value="提交" name="B1"><input type="reset" value="全部重写" name="B2"></p></form>用String year=request.getParameter("D1");String month =request.getParameter("D2");String day=request.getParameter("D3");就可以得到年、月、日啊!————————————————————————————————从数据库中调用数据,如何在列表框中显示????用html代码和jsp循环代码嵌套在一起显示:<form method="POST" action="--WEBBOT-SELF--"> year: <select size="1" name="D1">、<% while rs.next() {%> <option value=<%=rs.getstring("year")><%=rs.getstring("year")</option><% }%> </select>随手写的,仅做提示! 数据库字段有:year,month,day取值输出:while(rs.next()){ out.print("日期:"+rs.getString"year"); out.print("-"+rs.getString"month"); out.println("-"+rs.getString"day");}//以上是伪代码,不可直接使用。 ocde(酬英雄志,动儿女情) 你的select控件不会没起名字吧??lynx1111(任我行) 的做法是对的 lynx1111(任我行) 的做法是对的。ocde(酬英雄志,动儿女情) 你说返回null的话,select控件的名字是不是没定义,或写错了。例<select name="ssssss"> 自增字段设置 会asp.net学jsp难吗? struts2标签问题 ABB(中国)有限公司高薪诚聘 各位大姐大哥,帮助解决这个问题了,求求你们了 如何编写一个程序,让他在每天定时或隔几个小时自动运行一个方法,来进行一次数据库操作?环境为java,tomcat 新手,编写好的.java文件怎么样编译成.class文件,谢谢! 自己写的servlet为什么不能显示出来呢?初学者的问题! jsp实现打印功能???急急急 springmvc 视图解析器 怎样在一个网页里像IE打开文件一样,可以显示不同类型的文件? (急)如何得到我网站的根目录?
String month =request.getParameter("month");
String day=request.getParameter("day");
那就把你的年月日的值取得,然后拼成yyyy/mm/dd的形式存就可以了
Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException event)
{
}
try
{
con=DriverManager.getConnection("jdbc:odbc:数据源");
sql=con.createStatement();
String condition="insert into 表名 values"+"("+"'"+stryear+"')";
sql.executeUpdate(condition);
con.close();
}
catch(SQLException e)
{
}
<select name="mulSelect" size="1" multiple>
<option value="....">....
<option value="....">....
<option value="....">....
<option value="....">....
....
</select>提交后取值:
String[] strArray = request.getParameterValues("mulSelect");
if(strArray!=null && strArray.length>1){
for(int i=0;i<strArray.length;i++){
//生成SQL语句;
}
}
//执行数据库数据插入语句。
标签出怎墨写???我照 lynx1111(任我行)sgdb(神天月晓) 的话试了下返回null
另外;
从数据库中调用数据,如何在列表框中显示????
请高手赐教 !!!!
year:
<select size="1" name="D1">
<option value="1999">1999年</option>
<option value="2000">2000年</option>
</select>
month:
<select size="1" name="D2">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
</select>date:<select size="1" name="D3">
<option value="1">1日</option>
<option value="2">2日</option>
<option value="3">3日</option>
</select><input type="submit" value="提交" name="B1"><input type="reset" value="全部重写" name="B2"></p>
</form>
用
String year=request.getParameter("D1");
String month =request.getParameter("D2");
String day=request.getParameter("D3");
就可以得到年、月、日啊!
————————————————————————————————
从数据库中调用数据,如何在列表框中显示????
用html代码和jsp循环代码嵌套在一起显示:
<form method="POST" action="--WEBBOT-SELF--">
year:
<select size="1" name="D1">、
<%
while rs.next()
{
%>
<option value=<%=rs.getstring("year")><%=rs.getstring("year")</option>
<%
}
%>
</select>
随手写的,仅做提示!
while(rs.next()){
out.print("日期:"+rs.getString"year");
out.print("-"+rs.getString"month");
out.println("-"+rs.getString"day");
}
//以上是伪代码,不可直接使用。
你的select控件不会没起名字吧??
lynx1111(任我行) 的做法是对的
ocde(酬英雄志,动儿女情) 你说返回null的话,
select控件的名字是不是没定义,或写错了。
例<select name="ssssss">