www.webdeveloper.com
Results 1 to 2 of 2

Thread: Multiple checkbox insert database

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Unhappy Multiple checkbox insert database

    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

  2. #2
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    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.


    Code:
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles