Here is one way to do it...I imagine there lots of other ways:

You need two arrays, one for your available languages and one for your
selected languages.  Loop through each available language, and for each
available loop through the array of selected -- if the current available
language exists in the selected array, then put the "SELECTED" in the
<option> tag.  Below is an example:

<select multiple size=6 name=resourceLanguageId>

#foreach ($lang in $languages)
  #set( $selected = "" )
  #foreach ($slctlang in $selectedLanguages)
    #if( $lang.id == $slctlang.id)
      #set( $selected = "SELECTED" )
    #end
  #end
  <option value="$lang.id" $selected>$lang.name</option>
#end

</select>

NOTE:  You don't need the "[]" in "resourceLanguageId[]" in Turbine.  Use
the data.getParameters().getStrings() to fetch an array.

ANOTHER NOTE:  You can simplify this a little using Intake and the
multiValued="true" field attribute.

Good luck,

Chris


> -----Original Message-----
> From: Luke Majewski [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 27, 2003 9:32 PM
> To: [EMAIL PROTECTED]
> Subject: passing info from multiple select list
>
>
> I'm having trouble passing the information from my multiple
> select list in Velocity to my java code.
>
> <select multiple size=6 name=resourceLanguageId[]>
>
>         #foreach ($lang in $languages)
>             <option value="$lang.id"
>             #if ($lang.flag) selected #end
>         >$lang.name
>         #end
>
>     </select>
>
> Displaying the select list items is fine, it's how to tell my
> java code which items are selected that's giving me trouble .
> Can anyone point me the right direction?
>
> Thank you,
>
> Luke Majewski
> Center for Promotion of Child Development Through Primary Care


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to