[ https://issues.apache.org/jira/browse/WW-3182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart resolved WW-3182. ------------------------------- Assignee: Lukasz Lenart Resolution: Fixed Solved, thanks for reporting! > removeOptions will not remove some select option > ------------------------------------------------- > > Key: WW-3182 > URL: https://issues.apache.org/jira/browse/WW-3182 > Project: Struts 2 > Issue Type: Bug > Affects Versions: 2.1.6 > Environment: Struts2.1.6 + Tomcat 6.0.20 + Firefox 3.5 > Reporter: Gene Wu > Assignee: Lukasz Lenart > Fix For: 2.2.0 > > > removeOptions is incorrect. > /struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/inputtransferselect.js > for example we have a list of {1,2,3,4,5,6}, among it, we select 2,3,4. Click > remove button. It will left some of them. The reason is > function removeOptions(objTargetElement) { > for(var i=0;i<objTargetElement.options.length;i++) { > if(objTargetElement.options[i].selected) { > objTargetElement.options[i] = null; > } > } > } > before you remove "2" from this list. the length is 6. the i will be 1 > after removing "2", in the next iteration, i will be 2, but now the option[2] > point to the 4. Apparently, "3" was left! > my workaround is: > function removeOptions(objTargetElement) { > for(var i=0;i<objTargetElement.options.length;i++) { > if(objTargetElement.options[i].selected) { > objTargetElement.options[i] = null; > i--; > } > } > } > correct me, if I was wrong. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira