I am working on a script that performs the filtering function of say Item B based on Item A. Item A and B are both dropdown lists. Consider a DCR is saved with the filterer elements A and filteree element B selected. When that DCR is edited, the filtering has to apply to it at the load time and also the drop down element B should contain the selected value based on the item selected in list A. What happens is when that list loads up the first time, it doesn't select anything in List B although it does select List A. The List B however has correct filtered value list. If List is toggled from one item to another and back to the initially selected item, the List B selects the correct item as per the DCR save. Also if I uncomment the alert just before the option list built for selected item, the script works just fine. I am assuming that their is some timing issues involved during the initial loading. Following is the snippet from the call and Option List Built functions.
Call:
var pageSelectItem = IWDatacapture.getItem(prodPath)
// this function setOption the Option list passed to it with the correct item selected
customSetOptions(pageSelectItem, filterSel(tempArray1, OptionArrayProd, SavedProdArr)); IWDatacapture.redraw();
Option List Built:
function filterSel(arrayToFilter, itemOptionArrayFromDCT, savedArray)
{
...
...
newOptions[0] = new Option("---Please Select---", "", false, false);
for (var a=0; a<tempArrayLabel.length; a++)
{
var label =new String(tempArrayLabel
);
var value =new String(tempArrayValue);
var savedVal = new String(savedArray);
if (savedArray == tempArrayValue)
{
//alert(savedArray +"=="+ tempArrayValue);
newOptions[a+1] = new Option(label, value, false, true);
}
else
{
newOptions[a+1] = new Option(label, value, false, false);
}
}
return(newOptions); //return the option list
}
Any help would be appreciated.