<html:select property="fields" multiple="true" style='width:200px;'>
<html:options property='fieldsOptions'/>
</html:select>
fields is a String[] and fieldsOptions is an ArrayList I populate. When I do:
var selected = document.forms[0].fields;
It returns an array that has all of the options and not just the ones that have been selected. I just want to be able to look at the selected options. Remove them from fieldsOptions and move them into another selectedFields select
document.forms[0].fieldsis theselectDOM element. You must iterate through its options and get the ones which are selected. See https://developer.mozilla.org/en/DOM/HTMLSelectElement for the documentation (in Mozilla) of the element. It shouldn’t be much different in other browsers.Note that cross-browser APIs like JQuery have cool shortcut methods to do this (See http://api.jquery.com/val/ )