Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   asp list box to list box transfer JS. (http://www.programmingforums.org/showthread.php?t=13617)

piercy Jul 25th, 2007 5:15 AM

asp list box to list box transfer JS.
 
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


All times are GMT -5. The time now is 9:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC