Changing dropdown box to list box: selecting multiple items
I have changed a drop down box to a multi-line list box on my jsp form so users can select more than one option. However, when I select more than one, and submit the form, only the records for the first option are displayed. How do I call multiple records?
Here is the code for the new list box:
<select name="statusSel" size="3" multiple="multiple" >
<option value="1" ><%=ListBean.getStatusSel().equals("1") ? "selected" : ""%> >1</option>
<option value="2" ><%=ListBean.getStatusSel().equals("2") ? "selected" : ""%> >2</option>
<option value="3" ><%=ListBean.getStatusSel().equals("3") ? "selected" : ""%> >3</option>
</select>
[750 byte] By [
MDwyer75a] at [2007-11-27 6:03:31]

> ListBean.getStatusSel().equals("1")
This code suggests to me that the ListBean object returns THE selected value. So if you want to have more than one selected value, you're going to have to redesign the class that object belongs to so that it allows more than one selected value. Your new code might look something like this, depending on the design:
> ListBean.isSelected("1")
Thanks. One more thing.
Rather that the list box, could I have a drop down box with a new 4th option that would combine the records of two other options (or display all but one). For example:
<select name="statusSel" >
<option value="1" ><%=ListBean.getStatusSel().equals("1") ? "selected" : ""%> >1</option>
<option value="2" ><%=ListBean.getStatusSel().equals("2") ? "selected" : ""%> >2</option>
<option value="3" ><%=ListBean.getStatusSel().equals("3") ? "selected" : ""%> >3</option>
<option value="23" ><%=ListBean.getStatusSel().equals("23") ? "selected" : ""%> >2 and 3</option>
</select>
Would this require an if statement or change to the class?
> Would this require an if statement or change to the
> class?
I would change the class, unless you can figure out some method of multiple quantum Java returns that will let you return 1, 2, and 23 all in the same string... ;)
Okay, I'm missing your point, but I think the "23" thing is a hack, and generally violates the purpose of the multiple select thingybobber.