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

multiple choice... 1

Status
Not open for further replies.

mjonson

Technical User
Joined
Mar 9, 2004
Messages
128
Location
GB
Hi,

am trying to let users select multiple
choices.
the source of the choices is a table.
so far i have the code below that users can select
multiple items from a combo box.
this is ok apart from two things:

1) the combo is 4 rows long and you have to scroll
down to see other choices. how can you adjust how many rows are shown

2) the data is stored in a field as comma separated values. this will make running queries tricky.
i started by making a linked table that would store values
in a list as you would in 1 to many relationship but have given up - any examples of code to do it properly would be most welcome

<code>
<%
x_stockaccList = "<select name='x_stockacc' multiple>"
sqlwrk = "SELECT `accid`, `accdesc` FROM `tbl_acc`" & " ORDER BY `accdesc`"
Set rswrk = Server.CreateObject("ADODB.Recordset")
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.Eof Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)

'Dim ar_x_stockacc, ari_x_stockacc
ar_x_stockacc= Split(x_stockacc&"",",")
For rowcntwrk = 0 To rowswrk
x_stockaccList = x_stockaccList & "<option value='" & datawrk(0, rowcntwrk) & "'"
For ari_x_stockacc=0 to UBound(ar_x_stockacc)
If CStr(datawrk(0, rowcntwrk)&"") = Trim(ar_x_stockacc(ari_x_stockacc)&"") Then
x_stockaccList = x_stockaccList & " selected"
Exit For
End If
Next
x_stockaccList = x_stockaccList & ">" & datawrk(1, rowcntwrk) & "</option>"
Next
End If
rswrk.Close
Set rswrk = Nothing
x_stockaccList = x_stockaccList & "</select>"
Response.Write x_stockaccList
%>
</code>
 
This should solve your question 1:

x_stockaccList = "<select name='x_stockacc' size=4 multiple>"

-L
 
heres a * lothario thank u
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top