Subject: dynamic alteration of multiple entry select box content with javascript : empty values upon submission From: Simon Kirk <[EMAIL PROTECTED]> === Hello.
I have an html page with two select boxes configured to allow multiple selection in each. The one on the left contains options that are available, the one on the right contains options that are selected from those available. I've got a javascript method suite that will transfer selected options from the box on the left to the box on the right dynamically. I know it works with normal html form submission as I've used it many times in the past. Now however I'm trying to get it to work with struts. The first problem I came across was populating the select boxes. Not normally a problem, but the form bean I had configured to accept the data from the html page complained about various problems. Finally I got this nailed. Here's an example of the html: <table cellspacing="0" cellpadding="0" border="0"> <tr> <td align="center">Available options</td> <td align="center"> </td> <td align="center">Selected options/td> </tr> <tr> <td align="center"> <html:select property="allOptions" size="5" multiple="multiple"> <html:options collection="options" property="value" labelProperty="label"/> </html:select> </td> <td align="center"> <input type="button" name="addoption" value=" >> " onclick="moveSelectedOptions('fooForm','allOptions','selectedOptions')"> <br><br> <input type="button" name="deloption" value=" << " onclick="moveSelectedOptions('fooForm','selectedOptions','allOptions')"> </td> <td align="center"> <html:select property="selectedOptions" size="5" multiple="multiple"> <html:options property="options" labelProperty="optionLabels"/> </html:select> </td> </tr> </table> (please excuse any shonky indentation :) I won't paste the javascript functions up here as they're pretty long winded. The top select box gets its options from a bean containing a collection of LabelValue beans. The bottom select box gets it options from a collection contained in the form bean, which is populated from the database with an Action before the form is rendered. Now, if you click one of the two buttons labelled >> or << the options move across into the relative box as expected. But when I submit the form I am getting nothing at all in the form bean for either the property "allOptions" or "selectedOptions". Nothing at all, not a null value, just nothing. This is independant of the type that you set that field to in the form bean class you make - struts isn't doing anything clever like turning the multiple selection into a Vector on the fly for you. The selected options should come through as a comma seperated list of IDs. If anybody has any idea where to go I would be very helpful, as reading through the mailing list archive and checking google hasn't really given me any useful information. Is there anywhere I can check every value being gleaned out of the form by the controller servlet? Printing the query string out in the action class that the html page forwards off to doesn't help, it's empty too. Regards, Simon -- Simon Kirk perception|be.developer(java) t. +44 (0) 20 7689 1200 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>