javascript ¶ÔListBoxµÄÔö ɾ
¼ÙÉèÓÐ2¸öListBox£¬ID·Ö±ðΪlbLeft£¬lbRight
Ñ¡ÖÐlbLeftÀïµÄÏîÌí¼Óµ½lbRightÀï:
function add()
{
var left;
var right;
left = document.getElementById("lbLeft");
right = document.getElementById("lbRight");
for(var i=0;i<left.length;i++)
{
if(left.options[i].selected)
{
//ÅжϸÃÏîÊÇ·ñÒѾ´æÔÚ
for(j=0;j<right.length;j++)
{
if(right.options[j].value==left.options[i].value)
{
return;
}
}
right.add(new Option(left.options[i].text,left.options[i].value));
}
}
}
ɾ³ýlbRightÀïµÄÏ
function del()
{
right=document.getElementById("lbRight");
for(i=right.length-1;i>=0;i--)
{
if(right.options[i].selected)
{
right.remove(i);
}
}
//ÖØи³Öµ
for(j=0;j<right.length;j++)
{
document.getElementById("txtAllName").value+=right.options[j].text+",";
document.getElementById("txtAllID").value+=right.options[j].value+",";
}
}
¡¡