Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Obtaining Multiple Values from List Boxes


Message #1 by "Young, Ashley" <Ashley.Young@c...> on Tue, 6 Aug 2002 16:27:04 -0400
I'm sure this has been asked several times, but hopefully someone will
answer it for me anyway. I have several list boxes that I want to get values
from to perform an asp sql query with.

How do I get the multiple selected values from the list box?

All help is appreciated.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
 
Message #2 by Karri Peterson <KPeterson@C...> on Tue, 6 Aug 2002 16:00:26 -0500
http://www.brettb.com/ASPMultiSelectInputBoxes.asp

that's a pretty good link on how to work with this--

Karri 

-----Original Message-----
From: Young, Ashley [mailto:Ashley.Young@c...]
Sent: Tuesday, August 06, 2002 3:27 PM
To: Access ASP
Subject: [access_asp] Obtaining Multiple Values from List Boxes



I'm sure this has been asked several times, but hopefully someone will
answer it for me anyway. I have several list boxes that I want to get values
from to perform an asp sql query with.

How do I get the multiple selected values from the list box?

All help is appreciated.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
 

Message #3 by "Charles Mabbott" <aa8vs@m...> on Tue, 06 Aug 2002 20:17:12 -0400
Ashley,

Here is an example from book, as applied to ham radio web page.

<%
  Option Explicit
  Dim strConnect
%>
<!-- #include file="DaXXXtXXXX1.asp" -->
<!-- METADATA TYPE="typelib"
              FILE="C:\Program Files\Common Files\System\ado\msado15.dll" 
-->
<!-- #INCLUDE FILE="RecToTable.asp" -->
<HTML>
<HEAD>
<TITLE>Find Member I94</TITLE>
</HEAD>
<BODY>
<%
  Dim strSQL            ' SQL String
  Dim objRS, objField   ' ADO Recordset and Field objects
  Dim intCount          ' number of fields selected
  Dim vbQuote           ' quote character
  vbQuote = Chr(34)

  Response.Write "<H2>Find Member by Call</H2>"

  ' Check whether the user has checked any boxes to select some fields.
  ' If so, we'll display a table of data
  If Request.Form("Field").Count > 0 Then
    ' Find out which fields are to be selected
    strSQL = ""
    For intCount = 1 to Request.Form("Field").Count
      strSQL = strSQL & Request.Form("Field")(intCount) & ", "
    Next

    ' Strip the trailing comma and space (added in the loop) from end of 
strSQL
    strSQL = Left(strSQL, Len(strSQL) - 2)

    ' Add the SELECT command and the FROM criteria
    strSQL = "SELECT " & strSQL & " FROM members"

    ' If user requested a particular member, add a WHERE clause
    ' (otherwise they'll get data for all members)
    If Request.Form("Director") <> "" Then
      strSQL = strSQL & " WHERE callid LIKE '" & Request.Form("Director") & 
"'"
    End If

    ' Create the recordset
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    objRS.Open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, 
adCmdText

    ' Write a table of the recordset
    Response.Write RecToTable (objRS)

    ' Clean up
    objRS.Close
    Set objRS = Nothing
  End If
%>

<FORM NAME=MemberInfo ACTION="FindBycall.asp" METHOD="POST">
  Enter the Call sign to find:
  <INPUT TYPE="TEXT" NAME="Director"><BR><BR>

  Please select which fields you would like review :<BR>
  <%
    ' Create a recordset on the Members table
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    objRS.Open "Members", strConnect, _
                    adOpenForwardOnly, adLockReadOnly, adCmdTable

    ' Create a checkbox in the form for each field in the recordset
    For Each objField in objRS.Fields
      Response.Write "<INPUT TYPE=CHECKBOX NAME=" & vbQuote & "Field" & 
vbQuote & _
                     " VALUE=" & vbQuote & objField.Name & vbQuote & ">" & _
                     objField.Name
    Next
    objRS.Close   ' clean up
    Set objRS = Nothing
  %>
  <BR><INPUT TYPE=SUBMIT VALUE="Find"><INPUT TYPE=RESET VALUE="Clear">
</FORM>
<center>

<a href="upkeep.asp#top">Maintenance</a>  page

<h3>Last update: 9/22/01</h3>
</BODY>
</HTML>

Regards,
Chuck
================================================

>From: "Young, Ashley" <Ashley.Young@c...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] Obtaining Multiple Values from List Boxes
>Date: Tue, 6 Aug 2002 16:27:04 -0400
>
>
>I'm sure this has been asked several times, but hopefully someone will
>answer it for me anyway. I have several list boxes that I want to get 
>values
>from to perform an asp sql query with.
>
>How do I get the multiple selected values from the list box?
>
>All help is appreciated.
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
>
>




"If your not part of the solution,
there is good money to be made
prolonging the problem."


http://68.43.100.7:81/aa8vs


_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


  Return to Index