如何把多条选上的复选框数据保存到数据库 在线等
如何把多条选上的复选框数据保存到数据库
下面是我写的代码
<%
String C_Roles_ID[] =request.getParameterValues( "C_cRoles_ID ");
String id=request.getParameter( "ID ");
String userIdAll = " ";
String deleteResult = " ";
SJUsr sr = new SJUsr();
if(C_Roles_ID!=null)
{
for(int i=0;i <C_Roles_ID.length;i++)
{
userIdAll=userIdAll + C_Roles_ID[i] + ", ";
}
userIdAll = userIdAll.substring(0, userIdAll.length()-1);
}
deleteResult = sr.insertRU(userIdAll,id);
%> 这样从进去的数据就一条,而且复选框的值变成了“.”
[解决办法]
String C_Roles_ID[] =request.getParameterValues( "C_cRoles_ID ");
String id=request.getParameter( "ID ");
String userIdAll = " ";
String deleteResult = " ";
SJUsr sr = new SJUsr();
if(C_Roles_ID!=null)
{
for(int i=0;i <C_Roles_ID.length;i++)
{
//把C_Roles_ID[i]插入数据库
}
}