Entry
How do I populate a second multiple select by selecting options in a first multiple select?
Nov 25th, 2004 04:31
Hans Decheveir, z - design,
// To copy multiple select box values from one multiple select box to
// another multiple select box:
function copySelectValues() {
var selSource = document.formName.selSourceName;
var selTo = document.formName.selToName;
for (var i = 0; i < selSource.options.length; i++) {
if (selSource.options[i].selected) {
var newOption = new Option(selSource.options[i].text,
selSource.options[i].value);
selTo.options[selTo.options.length] = newOption; } }
// Use the function below to delete options from selSource after the
// copying
deleteOptions(selSource)
}
function deleteOptions(selDelete) {
for (var i = 0; i < selDelete.options.length; i++) {
if (selDelete.options[i].selected) {
selDelete.options[i] = null;
i=-1 } } }