Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Selecting items in a list from a multivalue field

New Here ,
Mar 07, 2007 Mar 07, 2007
I have an edit page that includes a menu form element that allows multiple selections. It inserts all the IDs from a table that it's got from a recordset as a string into field named EventType separated by commas ("10000,10002,10004"). So far so good.

I have a dynamic menu behaviour on the edit page too but when I reload it none of the options in the list are selected. It will mark an item in the menu as selected when there's only one value, presumably because when there are multiples the behaviour is trying to match a string of "10000,10002,10004" to the values in the the list , which are separate values:

<select name="EventType" size="5" multiple="multiple" id="EventType">
<option value="10001" >Abseil</option>
<option value="10007" >Golf</option>
<option value="10000" >Marathon/Run</option>
<option value="10008" >Other outdoor</option>
<option value="10003" >Overseas</option>
<option value="10005" >Social</option>
<option value="10006" >Triathlon</option>
<option value="10004" >Walking</option>

I'd have thought this would have been dealt with by the behaviour, but apparently not. How to I break apart the multivalue field to select each item in the menu?
TOPICS
Server side applications
241
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 07, 2007 Mar 07, 2007
Store the values in an array, then loop through the array to create the select options.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2007 Mar 07, 2007
LATEST
Thank you for poitning me in the right direction. I was being a little slow today:

While (NOT rsEventType.EOF)
%><option value="<%=(rsEventType.Fields.Item("ID").Value)%>" <%
Array = Split(rsEvent.Fields.Item("Type").Value,", ")
For Each i In Array
If rsEventType.Fields.Item("ID").Value = i Then
response.write "selected"
End If
Next
%>><%=(rsEventType.Fields.Item("EventType").Value)%></option>
<%
rsEventType.MoveNext()
Wend
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines