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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple select

Status
Not open for further replies.

Ravala

Programmer
Jan 28, 2004
88
US
How can I do multiple select option.
My code is:
<select name="cboOrderTypeBrand" id="cboOrderTypeBrand">
<%
Set objRS = GetOrderTypesRecordSet()
While not objRS.EOF
response.Write("<option value=" & objRS("CODE").Value & ">" & objRS("CODE").Value & "</option>")
objRS.MoveNext
Wend
objRS.Close
Set objRS = Nothing
%>
</select>
Thanks.
 
Code:
<select name="cboOrderTypeBrand" id="cboOrderTypeBrand" [b][red]Multiple[/red][/b]>
        <%
        Set objRS = GetOrderTypesRecordSet()
        While not objRS.EOF
            response.Write("<option value=" & objRS("CODE").Value & ">" & objRS("CODE").Value & "</option>")
            objRS.MoveNext
        Wend
        objRS.Close
        Set objRS = Nothing
        %>
        </select>
 
Just add "multiple" in your beginning select tag:
<select name="cboOrderTypeBrand" id="cboOrderTypeBrand" multiple>

-T

barcode_1.gif
 
But I return just first select element.
 
It will pass a comma-delimited list of all the selected elements. So if your select looked like this:
Code:
<select name="selColors" multiple">
   <option>red</option>
   <option>blue</option>
   <option>yellow</option>
   <option>green</option>
</select>

And you selected the first and last color, then you could read them on the next page like this:
Code:
Response.Write Request.Form("selColors")
'or
Dim color
For Each color in Request.Form("selColors")
   Response.Write color & "<br>"
Next

The first statement would output: red, green
the second statement (for loop) would output:
red<br>
green<br>

-T

barcode_1.gif
 
I have to pass onSubmit this string as selection formula (sf) to Crystal Report.
I don't know much javascript,
My sf should look like "ORDER_TYPE IN ('type1','type2')
 
That would be a javascript question then, not ASP, you can find the javascript forum here: forum216

barcode_1.gif
 
Hello, my question is related to all of the above.
I have a multiple select statement, passing to another page.
I get the select box data on the 2nd page as - i.e

'Red,Green'

but I am using this field to put in SQL statement for SQL Server, which doesn't work as SQL Server needs the text as
'Red','Green'.

anyone any ideas
regards
Steve
 
I use a couple functions to split() the string on the comma then add quotes to each word in the array and reconstruct the string and commas,



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
If they're all strings (which with the ORDER IN sql I'd assume they are) you could do it like this (separated into multiple lines to make it more clear, you can merge the whole concatenation into one to speed it up a bit):
Code:
strSQL = strSQL & "ORDER_TYPE IN ('"
strSQL = strSQL & Replace(Request.Form("cboOrderTypeBrand"), ",", "','")
strSQL = strSQL & "')"
This would put the beginning parenthesis and single quote at the beginning, then change something like
Code:
red,green,blue
into
Code:
red','green','blue
using Replace(), and then it would add the ending single quote and parenthesis to the end.

All of this assumes what you meant was that you needed a way to do this in VBScript on the server (in ASP), which is what I think you meant, not Javascript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top