Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with INSERT from LIST Box

Status
Not open for further replies.

dcwave

IS-IT--Management
May 18, 2003
46
0
0
US
I have a HTML List box (<select multiple>) that is populated from a table.

I need the user to select multiple options. Then insert into a second table the selections with the same selection ID. I am assuming I need to loop my insert statement somehow, I'm just not sure how. Can anyone help? Thanks

 
here something like this:

lets say you have a query that gives you item names from
your tables

Code:
sql = Select ItemId, ItemName from myitemstable"

rsitem.Open sql, conn

now to build the list...

 <select size="1" name="itemname">
      <option>-Select One-</option>
      
      <% While Not rsitem.EOF %>
      <option value="<%=rsitem.Fields("ItemId")%>"><%=rsitem.Fields("ItemName")%></option>

      <%
      	rsitem.MoveNext
      	Wend
      %>
      </select></td>

Hope this helps...

-DNG
 
Thanks, much... I figured out what I needed using this... duh.

Code:
	<form name="testform" action="inserttest.asp" method="post">
		<select multiple name="list">
			<option value="1">One</option>
			<option value="2">Two</option>
			<option value="3">Three</option>
		</select>	
		<input type="submit"/>
	</form>


	dim item
	for each item in request("list")
	  sql = "INSERT INTO inputtest (teststring) values (" & item & ")"
	  con.Execute(SQL)
	
	next
 
but in your case you are building the list static...in case you wanted to build the list dynamically by retrieving the date from the the database, you can then use my example...

gald to help...

-DNG
 
yeah.. building dynamically I have done.. The seemingly hard part was splitting out the result.

Thanks again for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top