I'm setting up a select multiple box to allow multiple values to be added to a database at once, and using the below code:
<select name="add" style="width: 100%; height: 100px" multiple>
<%
do until rsCategory.bof or rsCategory.eof = true
%>
<option value="<%=rsCategory("catID")%>"><%=rsCategory("Cat")%></option>
<%
rsCategory.movenext
loop %>
</select>
This code works just fine displaying the multiple select, and is a twist on an existing dropdown box I have for a single select I have. The trouble I'm having is converting the below code to input the multiple values into the SQL database, as opposed to just one value:
<!-- #include virtual = "includes/coredataconn.asp " -->
<!-- #include virtual = "includes/cleansql.asp" -->
<%
if session("customername") <> "admin" then response.redirect "logout.asp"
accID = cleansql(request.form("accountID"))
catId = cleansql(request.form("add"))
set rsNU = server.createobject("adodb.recordset")
sqNU = "SELECT * FROM categoriestable WHERE ((([AccountNo])='"& accID & "') OR accountID='"& accID & "');"
rsNU.open sqNU, cnnCore, 3, 3
rsNU(catId) = "Y"
rsNU.update
response.Redirect "../admin_categories.asp?account="& accID
%>
I would have imagined some sort of for loop would work but I'm struggling to get it right. Does anyone have any ideas?
Thank you in advance.