checkbox数组传值并UPDATE数据库的问题
各位DX,小弟遇到个难题,请大家给点思路
有个页面如下:
<%set rs=server.createobject( "adodb.recordset ")
sql= "select * from PRODUCT "
rs.open sql,conn,1,1%>
<form name= "order " action=>
<tr bgcolor= "#FFFFFF ">
<td width= "44 " height= "40 " align=center> ITEM </td>
<td width= "45 " height= "40 " align=center> QTY </td>
<td width= "10 " height= "40 " align=center> </td> </tr>
<%do while not rs.eof%>
<tr>
<td width= "44 " height= "40 " align=center> <%=rs( "ITEM# ")%> </td>
<td width= "45 " height= "40 " align=center> <%=rs( "QTY ")%> </td>
<td width= "10 " height= "40 " align=center> <input type=checkbox> </td> </tr>
<%rs.movenext
loop%>
<tr> <td> <select size= "1 " name= "factory ">
<option value= " " selected> 选择制造商 </option>
<option value= "1 "> 1号工厂 </option>
<option value= "2 "> 2号工厂 </option>
<option value= "3 "> 3号工厂 </option> </select> </td>
<td> <input class= "hand " type= "submit " value= "出货 " </td> </tr>
</form>
该页面先将PRODUCT表中的产品记录循环读取出来
需要完成的功能是:通过选择产品项ITEM后的CHECKBOX,将数据库中PRODUCT表的制造商ORDER属性,UPDATE为SELECT下拉框中相应的制造商
不知道怎样读取多个checkbox的值,请大家帮帮忙,谢谢,分不够再开
------解决方案-------------------- <input type=checkbox name= "ItemID " value= " <%=rs( "ID ")%> ">
通过
Dim strIds
strIds = Request.Form[ "ItemID "]
得到一个字串,
如 1,4,6,7
然后
sql = "Update Product set order = " & Request.Form[ "factory "] & " WHERE ID IN( " & strIds & ") "
当然应该检查strIds和 Request.Form[ "factory "] 的合法性.
------解决方案-------------------- <input type=checkbox name= "box1 " value= " <%=rs( "ITEM# ")%> ">
然后你在处理页面用 request( "box1 ") 就可以得到被选中的 ITEM#,它们是用逗号分隔的
------解决方案--------------------记下ID,然后写进数组,循环更新语句即可
------解决方案--------------------考虑下用select case value
end select
来实现读取
------解决方案-------------------- <%set rs=server.createobject( "adodb.recordset ")