rem: var i = 0; var opt;  while (i < from.options.length) { if (from.options[i].selected) { opt = new Option(from.options[i].text, from.options[i].value); if (to && to.options) { to.options[to.options.length]=opt } else if (to && to.add) { to.add(opt) } if (from.options.length > 1) { try { from.options[i-1].selected = true; } catch(ex) { from.options[i+1].selected = true; from.remove(i); ++i; continue; } } from.remove(i); continue; } i++; 
add: var i; var len = from.options.length; for(i=0;i<len;++i) { if (!from.options[i].selected) continue; if (to && to.options) to.options.appendChild(from.options[i]); else from.removeChild(from.options[i]);  if (len > 1) from.options[i == len - 1 ? len - 2 : i].selected = true; break; 
context: function dualSelect(from, to, id) {    if (typeof(from) == 'string') {        from = $(from+id);    }    if (typeof(to) == 'string') {        to = $(to+id);    }    var i = 0;    var opt;    while (i < from.options.length) {        if (from.options[i].selected) {            opt = new Option(from.options[i].text, from.options[i].value);            if (to && to.options) {              to.options[to.options.length]=opt            } else if (to && to.add) {              to.add(opt)            }            if (from.options.length > 1) {                try {                    from.options[i-1].selected = true;                } catch(ex) {                    from.options[i+1].selected = true;                    from.remove(i);                    ++i;                    continue;                }                            }            from.remove(i);            continue;        }        i++;    }        updateDualSelectValue(id);}
meta: 6601	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/6601/2a6cea85a9e15d448734b73974c516286a78fa45/functions.js/buggy/javascript/functions.js