Click to See Complete Forum and Search --> : Multiple checkbox insert database


Mokaka
07-14-2009, 07:23 AM
Hi Good people

I have the form ,users check many checkboxes they want based on the question they want to submit,I want to store values of the checkbox they chose as numbers,ie I have checkbox from one to ten,so if they have chosen one to five ,I have to store those values in the database.


[code]

<li class="file"><input type="checkbox" name="txtIncident" value="<%=Node.iCategoryId%>" class="treeview"><font size="-1" color="navy"><%=Node.Category_Desc%><%=Node.iCategoryId%></font>


SQLStmt = "INSERT INTO table (iId, iCategoryId) SELECT '" &iId& "', CATEGORY_NO FROM n_table WHERE CATEGORY_NO IN ('"&request.form("txtIncident"
[End code]

or some one can help me on how to insert multiple checkbox into the database in ASP

yamaharuss
07-14-2009, 09:11 AM
Here is a sample of what I use.. in my application I have a dropdown which allows the user to select what action to take on the selected items.


strEditType = Request.QueryString("EditType")
If strEditType = "itemschecked" then
editCount = Request.QueryString("Count")
doWhat = Request.QueryString("doWhat")
for i = 0 to editCount-1
sID = Request("itemchecked_" & i)
if sID <> "" then

SELECT CASE doWhat
CASE "Del" ' DELETE ORDER
sql = "DELETE From Orders WHERE OrderID = " & sID
Conn.Execute(sql)
sql = "DELETE From OrderItems WHERE OrderID = " & sID
Conn.Execute(sql)
Session("M") = "OrdersDeleted"
Response.Redirect("?View=Sales")
CASE "Read" ' MARK AS READ
sql = "Update Orders Set Viewed = 1 WHERE OrderID = " & sID
Conn.Execute(sql)
Session("M") = "OrdersMarkedRead"
Response.Redirect("?View=Sales")
CASE "UnRead" ' MARK AS UNREAD
sql = "Update Orders Set Viewed = 0 WHERE OrderID = " & sID
Conn.Execute(sql)
Session("M") = "OrdersMarkedUnread"
Response.Redirect("?View=Sales")
END SELECT
end if
next

End If