removeOptions will not remove some select option 
-------------------------------------------------

                 Key: WW-3182
                 URL: https://issues.apache.org/struts/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


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.
-
You can reply to this email to add a comment to the issue online.

Reply via email to