Reading Multi-Select Combo Box Variables passed from an ASP page

Results 1 to 6 of 6

Thread: Reading Multi-Select Combo Box Variables passed from an ASP page

  1. #1
    Join Date
    Dec 1969
    Posts
    52

    Default Reading Multi-Select Combo Box Variables passed from an ASP page

    I have an ASP Page with several multi-select combo boxes that are pulled from an SQL 6.5 DB.<BR>I want to pass these variables to an ASP page.<BR>What is the best way to handle these variables in my SQL statement?<BR><BR>I would also like to use a Stored Procedure as well.<BR><BR>Any help would be appreciated!<BR>- Carl

  2. #2
    Chris Willey Guest

    Default RE: Reading Multi-Select Combo Box Variables passed from an ASP page

    I&#039m afraid SPs aren&#039t my thing, but I can get you started.<BR><BR>When you submit a multi-select combo box, you get a comma-delimited list of values back. What I do is just save that string to a database field, then when I extract it later I can use Split to show the disctinct values whenever I want:<BR><BR>myArray = Split(rs("field"), ",")<BR>For x = 0 to Ubound(myArray)<BR>Response.Write(myArray(x))<BR>N ext<BR><BR>Voila. I&#039m not sure if this gets at your question, but maybe it&#039s a start. I&#039m not clear if you&#039re populating a combo box from a field in SQL or if you&#039re saving choices from a combo box into a field in SQL. Can you give me more info?

  3. #3
    Join Date
    Dec 1969
    Posts
    52

    Default RE: Reading Multi-Select Combo Box Variables passed from an ASP page

    I am pulling the lists from my DB using the following:<BR>&#060;select name="status" multiple size="4" style="font-family: Tahoma; font-size: 10pt"><BR>&#060;option value="-" selected>--Select Status(s)--&#060;/option><BR>&#060;%<BR>&#039*********************** ************************************ <BR>statSQL = "SELECT DISTINCT value FROM log_statuses" Set statRS = objConn.Execute(statSQL)<BR> do while Not statRS.EOF status = statRS("value")<BR>&#039 Create and item for each Status in Delta<BR>&#037;&#062;<BR>&#060;option value="&#060;%= status &#037;&#062;">&#060;%= status &#037;&#062;&#060;/option><BR>&#060;%<BR>statRS.MoveNext<BR>Loop<BR>s tatRS.close<BR>&#037;&#062;<BR>&#060;/select><BR><BR>END<BR><BR>I then want to take these values and place them in my SELECT statemnt. Something like the following:<BR><BR>Select * from logs where status in (&#039status1&#039,&#039status2&#039,&#039statusN& #039)<BR><BR>I believe I will need to do a loop of some sort.<BR><BR>Thanks -<BR><BR>Carl<BR>

  4. #4
    Join Date
    Dec 1969
    Posts
    294

    Default RE: Reading Multi-Select Combo Box Variables passed from an ASP page

    I believe there is a count property for multiple selects.<BR><BR>For x = 1 to request.Form("whatever").count-1<BR><BR> &#039Build your string for the select here<BR><BR>Next<BR><BR>


  5. #5
    Chris Willey Guest

    Default RE: Reading Multi-Select Combo Box Variables passed from an ASP page

    I&#039m assuming that the SELECT statement is on a separate page that the form wherein your combo boxes are located submits to (yes that is an ugly sentence)?<BR><BR>I&#039ll just assume it is. Create your SQL by replacing the commas with single quotes, then tack on leading and closing single quotes:<BR><BR>mySQL = Replace(Request.QueryString("formfieldname"), ",", "&#039,&#039")<BR>mySQL = "&#039" & mySQL & "&#039"<BR><BR>Then write out your SELECT statement:<BR><BR>"SELECT * FROM logs WHERE status IN (" & mySQL & ")"<BR><BR>That should do it.

  6. #6
    Join Date
    Dec 1969
    Posts
    52

    Default RE: Reading Multi-Select Combo Box Variables passed from an ASP page

    Thanks Much - This worked GREAT!!!<BR><BR>I am successfully passing "5" mulit-select Variables in my form with success!!<BR><BR>Have a great weekend!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •