On 5-Apr-2004, =?Utf-8?B?Sm9lYW5kdGVs?= <an*******@discussions.microsoft.com>
wrote:
How do you retrieve data from a form when using a <select> tag that is set to
multiple?
I normally use: Request.Form("selectTagName"), but obviously it cannot work.
Please let me know what can be done.
in your form you have something that looks like:
<snip>
<tr>
<th>Please Select Organization</th>
<td align="center">
<select name="ORGID" onChange="swapOptions();" size=3 multiple>
<%do until ors.eof %>
<option value="<% =ors.fields("REL_ORGID").Value %>"><%
=ors.fields("REL_ORGID").Value %> - <%=ors.Fields("REL_COMP_TITLE").Value
%></option>
<% ors.MoveNext
loop %>
</select></font></td></tr>
<snip>
then you have a submit that runs another .asp file with:
<%@ Language="VBSCRIPT" %>
<%
server.ScriptTimeout = 999
avSSN = Request.Form("SSN")
avOHRID = Request.Form("OHRID")
if request.form("ORGID").count=0 then
%>
<html>
<head>
<title>Error</title>
</head>
<body>
<center>
<h2>Must Select Organization</h2>
<form><input type="button" value="Back" onClick="history.back();">
</form>
</body>
</html>
<%
Response.End
end if
SET dbobj = Server.CreateObject("ADODB.Connection")
dbobj.open "dsn=testdb;user id=tester;password=testy"
sql="SELECT ORG_ID, COURSE_REQUIRED, RESOURCE_MGR "&_
"FROM TBL_COURSE_REQ "&_
"where course_required <> ' '"&_
" and (ORG_ID='"& request.form("ORGID")(1) &"' "
if request.form("ORGID").count > 1 then
for i = 2 to request.form("ORGID").count
sql = sql & " or ORG_ID='"& request.form("ORGID")(i) &"' "
next
end if
sql = sql & ") order by ORG_ID "
set ors=dbobj.Execute(sql)
%>
So .count tells you how many items in the array and
request.form("<element>")(<array index>) ** i.e. request.form("ORGID")(1) **
will get you a specific reocrd from the array.
and you could walk the entire array with:
for i = 1 to request.form("ORGID").count
' whatever you wanted to do goes here
next
This sql code is for Oracle in this example.
Hopefully this is enough information to answer your question.
drew