吐血看不懂-纯javascript作的左右列表内容互换
<select name= "availableActivity "
ondblclick= "move(availableActivity,selectedActivity) "
multiple= "true ">
</select>
<select name= "selectedActivity "
ondblclick= "move(selectedActivity,availableActivity) "
multiple= "true ">
</select>
function move(fbox,tbox)
{
var i;
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
for(i=0;i <tbox.options.length;i++)
{
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength =0;
var tLength = arrTbox.length;
for(i=0;i <fbox.options.length;i++)
{
alert( "gg2 ");
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if(fbox.options[i].selected)
{
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else
{
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
fbox.length = 0;
tbox.length = 0;
var c;
for(c=0;c <arrFbox.length;c++)
{
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c=0;c <arrTbox.length;c++)
{
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
2个select有些数据,双击一个select数据,这条数据就跑到另外个select里
函数完全看不懂,那位大哥能帮着解释下?从arrLookup[tbox.options[i].text] = tbox.options[i].value;
这行大脑就乱飞了
------解决方案--------------------要用的时候再看
平时学基础