Here example of code.....
Code:
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY onload="SortAllItems();">
<TABLE>
<TR>
<TD> <select size="5" name="lstBox" id="lstBox">
<option value="A">A</option>
<option value="D">D</option>
<option value="C">C</option>
<option value="E">E</option>
<option value="B">B</option>
</select>
</TD>
<TD> <input name="add" type="button" value="Add" onclick="FirstListBox();" /> <input name="remove" type="button" value="Remove" onclick="SecondListBox();"/></TD>
<TD>
<select size="5" name="ListBox1" id="ListBox1">
</select>
</TD>
</TABLE>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function SecListBox(ListBox,text,value)
{
try
{
var option=document.createElement("OPTION");
option.value=value;
option.text=text;
ListBox.options.add(option)
}
catch(er)
{
alert(er)
}
}
function FirstListBox()
{
try
{
var count=document.getElementById("lstBox").options.length;
for(i=0;i<count;i++)
{
if(document.getElementById("lstBox").options[i].selected)
{
SecListBox(document.getElementById("ListBox1"),document.getElementById("lstBox").options[i].value,document.getElementById("lstBox").options[i].value);document.getElementById("lstBox").remove(i);
break
}
}
}
catch(er)
{
alert(er)
}
}
function SortAllItems()
{
var arr=new Array();
for(i=0;i<document.getElementById("lstBox").options.length;i++)
{
arr[i]=document.getElementById("lstBox").options[i].value}arr.sort();
RemoveAll();
for(i=0;i<arr.length;i++)
{
SecListBox(document.getElementById("lstBox"),arr[i],arr[i])}}function RemoveAll(){try{document.getElementById("lstBox").options.length=0
}
catch(er)
{
alert(er)
}
}
function SecondListBox()
{
try
{
var count=document.getElementById("ListBox1").options.length;
for(i=0;i<count;i++)
{
if(document.getElementById("ListBox1").options[i].selected){SecListBox(document.getElementById("lstBox"),document.getElementById("ListBox1").options[i].value,document.getElementById("ListBox1").options[i].value);document.getElementById("ListBox1").remove(i);
break
}
}
SortAllItems()
}
catch(er)
{
alert(er)
}
}
//-->
</SCRIPT>
</HTML>
It may use for you
Bookmarks