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>
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>