Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in getting selected values from multiselect list

 
R Laksh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two multiselect listboxes in my page. In List1 the data will be retrieved from DB and listed.I will have buttons to move the values from List1 to List2 and viceversa.

After selecting the needed values,I can rearrange them in List2 using some buttons. I have coded this moving and reordering using javascript.

What happens is while submitting the page I want the values from list2 which are rearranged. But im getting the order in which I moved from list1 to list2.

I am using html:selectfor both lists

List1
------
<html:select name="CustForm" property="custName" multiple="true" size="10">
<html ptionsCollection property="CustomerNames" value="custName" label="id"/>
</html:select>


I am having a customer form which has a arraylist CustomerNames. This arraylist has customer bean which has proeprties custName and id. The custForm also has a String custName.


List2
------
<html:select name="CustForm" property="selectedCustName" multiple="true" size="10">
<html ption value=""/>
</html:select>

The custForm also has a String[] selectedCustNames from where I get the selected values in list2


Please let me know what am I doing wrong here.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used a similar technique in letting users select values, but I have not had this problem. The only thing I might suggest is to make sure that your javascript causes all the options to be selected before submitting the form, as only selected values will be submitted. If you're already doing that, try unselecting all of them, then re-selecting them in the proper order.

Here is the function that I use to select all options:

 
R Laksh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah I have did this to select all the values from list2.

Actually while moving items up and down in list 2,in the script,I have swapped the text but didnt exchange the values. That was the problem and its fixed now.

Thanks a lot !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic