Hi Scott,
Here is some javascript code to move values between two listboxes.
<script language="javascript">
//This function adds the values from the fromlistbox to the tolistbox
function Move(fromList,toList)
{
//If no items are selected then display an error message and return
if(fromList.selectedIndex == -1)
{
alert('Please select atleast one record');
return;
}
var selIndex = fromList.selectedIndex;
var optionText = fromList.options[selIndex].text;
var optionVal = fromList.options[selIndex].value;
var optionIndex = toList.options.length;
//decalre a new listobject and add it to the other listbox
var objOption = new Option(optionText, optionVal);
toList.options[optionIndex] = objOption;
fromList.options[selIndex] = null;
}
//Adds the values from the left listbox to the right listbox
function AddVals()
{
var lstFrom = document.getElementById("lstFrom");
var lstTo = document.getElementById("lstTo");
Move(lstFrom,lstTo)
}
//Removes the values from the right box and adds them back to the left box
function RemVals()
{
var lstFrom = document.getElementById("lstTo");
var lstTo = document.getElementById("lstFrom");
Move(lstFrom,lstTo)
}
</script>
if you want to do it in server side its pretty straightforward like
ListBox2.Items.add(ListBox1.SelectedItem)
HTH
srini
Scott Reynolds said:
Hello!
Could someone provide me a sample code how to move values between two
ListBox controls?
Thank you!
Scott Reynolds