Hello,
I have 2 lists :
Personnel:
==========
test1
test2
Janet
Brown
Small
People:
==========
james
Wolter
McDonald
I have no problem transfering items from Personnel listBox to People listbox, but I do not seem to be able to transfer items from People list back to Personnel list.
It is so difficult to debug. I am wondering if any expert out there can help me out ? where did I screw up? or is there simplier way to make these 2 list boxes transfer items back and forth without the coding comlexity.
thanks in advance,
Ngai
===========================================
The following is my code...
===========================================
function copyToList(from,to)
{
var person = document.forms["Schedule"].person;
var personnel = document.forms["Schedule"].personnel;
fromList = eval('document.forms["Schedule"].' + from);
toList = eval('document.forms["Schedule"].' + to);
if (toList.options.length > 0 && toList.options[personnel.selectedIndex].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options;
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('You cannot move this text!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options = null;
i--;
}
}
if (!sel) alert ('You haven\'t selected any options!');
}
function allSelect()
{
List = document.forms["Schedule"].chosen;
if (List.length && List.options[personnel.selectedIndex].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options.selected = true;
}
}
I have 2 lists :
Personnel:
==========
test1
test2
Janet
Brown
Small
People:
==========
james
Wolter
McDonald
I have no problem transfering items from Personnel listBox to People listbox, but I do not seem to be able to transfer items from People list back to Personnel list.
It is so difficult to debug. I am wondering if any expert out there can help me out ? where did I screw up? or is there simplier way to make these 2 list boxes transfer items back and forth without the coding comlexity.
thanks in advance,
Ngai
===========================================
The following is my code...
===========================================
function copyToList(from,to)
{
var person = document.forms["Schedule"].person;
var personnel = document.forms["Schedule"].personnel;
fromList = eval('document.forms["Schedule"].' + from);
toList = eval('document.forms["Schedule"].' + to);
if (toList.options.length > 0 && toList.options[personnel.selectedIndex].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options;
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('You cannot move this text!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options = null;
i--;
}
}
if (!sel) alert ('You haven\'t selected any options!');
}
function allSelect()
{
List = document.forms["Schedule"].chosen;
if (List.length && List.options[personnel.selectedIndex].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options.selected = true;
}
}