i have two asp list boxs. one on the left is populated by test data eventually going to be data retrieved from the database. the user will select the certain info for instance usernames and then transfer them across to the other box for the web application to read.
ive got two buttons to transfer single or multiple values but i need two more buttons to transfer all between the two. this needs to be javascript as then there is no need to refresh the page.
function MoveItem(ctrlSource, ctrlTarget) {
var Source = document.getElementById(ctrlSource);
var Target = document.getElementById(ctrlTarget);
if ((Source != null) && (Target != null)) {
while ( Source.options.selectedIndex >= 0 ) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = Source.options[Source.options.selectedIndex].text;
newOption.value = Source.options[Source.options.selectedIndex].value;
Target.options[Target.length] = newOption; //Append the item in Target
Source.remove(Source.options.selectedIndex); //Remove the item from Source
}
}
}
this is the code i have inplace... then the list has a ondblclick() event and a normal button also has a onclick event. so something i can add into this on a new button to move all would be great. i looked around on net but couldnt find too much.. if some one has a link id be happy to follow that.
Thanks in advance,
Piercy