Hello.
I have two select option list boxes. Like:
- PC Elements and
- Elements.
When user select an PC element, Elements select list box is filled with those elements belonging to a selected PC Elements group.
My problem: not all Elements array consits of same number of options. Some are extra. I need to remove those extra from same select list.
Now, I have this javascript code for removing options:
function removeOption(arr, element)
{
for(i=0; i<arr.length; i++){
if(arr.search(';'+element)!=-1){
arr1 = arr.slice(0, i);
arr2 = arr.slice(i+1);
arr = arr1.concat(arr2);
return arr;
}
}
}
(as my options are stored in an arrays such as:
listOfOptions_motherboards = new Array(
"ASUS A7VK133;44",
"ASUS blah blah;45"
)
I call removeOption when building new list such as:
PCGroup = new Array();
PCGroup = PCGroup.concat(listOfOptions_motherboards);
PCGroup = removeElement(PCGroup, '25'); /*extra*/
PCGroup = removeElement(PCGroup, '39'); /*extra*/
return PCGroup;
But this doesn't work. I get my select list filled OK (when loaded) but I get 'error on page' when function removeObjects is parsed.
Perhaps my code is written false, HELP!
Thx.
I have two select option list boxes. Like:
- PC Elements and
- Elements.
When user select an PC element, Elements select list box is filled with those elements belonging to a selected PC Elements group.
My problem: not all Elements array consits of same number of options. Some are extra. I need to remove those extra from same select list.
Now, I have this javascript code for removing options:
function removeOption(arr, element)
{
for(i=0; i<arr.length; i++){
if(arr.search(';'+element)!=-1){
arr1 = arr.slice(0, i);
arr2 = arr.slice(i+1);
arr = arr1.concat(arr2);
return arr;
}
}
}
(as my options are stored in an arrays such as:
listOfOptions_motherboards = new Array(
"ASUS A7VK133;44",
"ASUS blah blah;45"
)
I call removeOption when building new list such as:
PCGroup = new Array();
PCGroup = PCGroup.concat(listOfOptions_motherboards);
PCGroup = removeElement(PCGroup, '25'); /*extra*/
PCGroup = removeElement(PCGroup, '39'); /*extra*/
return PCGroup;
But this doesn't work. I get my select list filled OK (when loaded) but I get 'error on page' when function removeObjects is parsed.
Perhaps my code is written false, HELP!
Thx.