how can insert multi-select items into access database? here is my code, PLEASE HELP.
<form name="become" method="post" action="becomesubmit.asp">
First Name:
<input name="firstName" type="text" size="25">
<br />
Last Name:
<input name="lastName" type="text" size="25">
<br />
What are your favorite colors?
<select name = "favecolors" multiple size = "5">
<option value = "All">All</option>
<option value = "None">None</option>
<option value = "Red">Red</option>
<option value = "Blue">Blue</option>
<option value = "Green">Green</option>
<option value = "Yellow">Yellow</option>
<option value = "Orange">Orange</option>
</select>
<input type="submit" name="submitbutton" value="Submit">
<br />
</form>
becomesubmit.asp:
<% @Language = VBScript %>
<%
Dim first, last, colors(5), connNewPerson, connFaveColor
first = (Request.Form("firstName"))
last = Request.Form("lastName")
SQL = "INSERT INTO personTable(FIRSTNAME, LASTNAME, "
SQL = SQL & ") VALUES ('" & first & "','" & last & "')"
set connNewPerson = server.createobject("ADODB.Connection")connNewPers on.open "userdb"
connNewPerson.execute(SQL)
connNewPerson.close
set connNewPerson = Nothing
'The above works beautifully and creates an auto-numbered primary key in the personTable.
Now to the problem, I need to get their favorite colors, if any, and put "true" or "yes" in the colorTable along with their primary key from the personTable and I don't want an auto-number to be created in colorTable. Follow?
For i = 1 to Request.Form("favecolors").Count
colors(i) = Request.Form("favecolors")
Next
SQLColor = "INSERT INTO colorTable "TRUE" or "YES" for ANY AND/OR ALL COLORS CHOSEN WHERE personTable.personID = colorTable.personID"
Here are the tables:
personTable:
personID | FIRST | LAST |
colorTable:
personID | RED | BLUE | GREEN | YELLOW | ORANGE |
ANY HELP IS APPRECIATED