How To Move Items Between Lists with JavaScript

You've seen pick lists in Windows where you select an item from one ListBox and it moves to a second ListBox (or vice versa). This solution shows you how to recreate that interface pattern in a browser.

by Tom Duffy

Jul 9, 2003

Page 1 of 4

ntil recently, moving data between HTML lists was problematic due to differences in each browser's DOM; however, as browsers move toward W3C DOM compliance, those differences are disappearing rapidly. In this article, I'll show you how to use standards-based DOM methods and JavaScript to move data from one HTML list to another.
You've seen those pick lists in Windows where you select an item from one ListBox and it moves to a second ListBox (or vice-versa). How can you recreate that interface pattern in a browser?

Use the Document Object Model (DOM) and some JavaScript to control the list's options array, and the task is easy.