newbie2006
07-28-2006, 02:16 AM
hi
i amm trying to do a javascript that needs to move items between 2 lists
I am catering for a multiple select here. However, even though the script works for a single
select, it doesnt work for multiple. Can someone help?
for single select:
var selectedList;
var availableList;
function createListObjects(){
availableList = document.getElementById("availableOptions");
selectedList = document.getElementById("selectedOptions");
}
function addAttribute(){
var selIndex = selectedList.selectedIndex;
if(selIndex < 0)
return;
availableList.appendChild(selectedList.options.item(selIndex))
selectNone(selectedList,availableList);
setSize(availableList,selectedList);
}
for multiple select
function addAttribute(){
for (int i=0; i<selectedList.length; i++){
var addIndex[i] = availableList.selectedIndex[i];
if(addIndex < 0)
return;
selectedList.appendChild(availableList.options.item(addIndex[i]));
}
selectNone(selectedList,availableList);
setSize(selectedList,availableList);
}
i amm trying to do a javascript that needs to move items between 2 lists
I am catering for a multiple select here. However, even though the script works for a single
select, it doesnt work for multiple. Can someone help?
for single select:
var selectedList;
var availableList;
function createListObjects(){
availableList = document.getElementById("availableOptions");
selectedList = document.getElementById("selectedOptions");
}
function addAttribute(){
var selIndex = selectedList.selectedIndex;
if(selIndex < 0)
return;
availableList.appendChild(selectedList.options.item(selIndex))
selectNone(selectedList,availableList);
setSize(availableList,selectedList);
}
for multiple select
function addAttribute(){
for (int i=0; i<selectedList.length; i++){
var addIndex[i] = availableList.selectedIndex[i];
if(addIndex < 0)
return;
selectedList.appendChild(availableList.options.item(addIndex[i]));
}
selectNone(selectedList,availableList);
setSize(selectedList,availableList);
}