<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>untitled document</title>
<script language= "JavaScript" >
function AddItem (objform)
{
var valueary=new Array ();
var textary=new Array ();
var leftelement=objform.elements["left"];
var rightelement=objform.elements["right"];
var count=0;
var I,j,k,flag;
for (i=0;i<leftelement.options.length;i++)
{
if (leftelement.options[i].selected)
{valueary[count]=leftelement.options[i].value;
Textary[count]=leftelement.options[i].text;
count++;
}
}
var count1=rightelement.options.length;
count1=count1>0?count1:0;
for (j=0;j<count;j++)
{
Flag=false;
for (k=0;k<count1;k++)
{
if (Rightelement.options[k].text==textary[j])
Flag=true;
}
if (!flag)
{
Rightelement.options[count1]=new Option (Textary[j],valueary[j]);
count1++;
}
}
}
function Subitem (objform)
{
var i;
var objelement=objform.elements["right"];
for (i=objelement.options.length-1;i>=0;i--)
{
if (objelement.options[i].selected)
Objelement.options[i]=null;
}
}
function Addallitem (objform)
{
var i;
var leftelement=objform.elements["left"];
for (i=0;i<leftelement.options.length;i++)
{
Leftelement.options[i].selected=true;
}
AddItem (Objform);
}
function Suballitem (objform)
{
var i;
var rightelement=objform.elements["right"];
for (i=0;i<rightelement.options.length;i++)
Rightelement.options[i].selected=true;
Subitem (Objform);
}
</script>
<body>
<table width= "cellpadding=" 0 "cellspacing=" 0 "border=" 0 ">
<form>
<tr>
<td "Width=" rowspan= "4",
<select name= "left" style= "width:80px;height:100px;" Multiple>
<option >ITEM1</option>
<option>ITEM2</option>
<option>ITEM3</option>
< Option>item4</option>
<option>ITEM5</option>
<option>ITEM6</option>
</select></td>
<td width= "height=" align= "center";
<input type= "button" value= " >> "onclick=" AddItem (This.form);
</td>
<td width= "rowspan=" 4 "align=" right ">
<select name=" right "style=" width:80px ; height:100px; "Multiple>
</select>
</td>
</tr>
<tr>
<TD width= "align=" center "><input type=" button "value=" << "onclick=" Subitem (this.form) "></ Td>
</tr>
<tr>
<TD width= "align=" center "><input type=" button "value=" all>> "onclick=" Addallitem (this.form) "> </td>
</tr>
<tr>
<TD width= "align=" center "><input type=" button "value=" <<all "onclick=" Suballitem (this.form) "> </td>
</tr>
</form>
</tr>
</table>
</body>
JS Select implements the left and right values. html