/* * selectList v1.2 * * This is a small library of functions that are used to copy items between * two * list are moved to the right lists before submitting the form, otherwise the server * program won't see them. The selectList(list_id) function is for that purpose. * * Copyright (c) 2001 - 2005 Mackley F. Pexton. All rights reserved. */ /* * Add the selected items in a list. * * If the unique flag is true then the selected items are added to the * destination list. * * The items deleted from the list by specifying it as the second srcList prameter. * */ function deleteFromDestList(destList,srcList) { var opt = new Object(); // track options that are deleted var len = destList.options.length; for(var i = (len-1); i >= 0; i--) { if ((destList.options[i] != null) && (destList.options[i].selected == true)) { if (srcList) opt[destList.options[i].value] = true; destList.options[i] = null; } } if (srcList && srcList.options) { // Select items in source list that were deleted. for (i = 0; i < srcList.options.length; i++) { if (opt[srcList.options[i].value]) { srcList.options[i].selected = true; } else { srcList.options[i].selected = false; } } } } /* * Move selected items in a list as "selected". * * Values in a list. */ function selectList(sourceList) { if (typeof sourceList == 'string') sourceList = document.getElementById(sourceList); for(var i = 0; i < sourceList.options.length; i++) { if (sourceList.options[i] != null) { sourceList.options[i].selected = true; } } return true; }