Hello,
I've been struggling with this simple code and looking for some help here. In my DCT, I have 2 sections, the
brand select item is in the first tab. The test code I'm writing just gets all the items from
getRootItems() and subsequently loops recursively down through the children until a match is made for a
select item with the path name
brand:
// This function gets the BRAND value
function getBrandValue(item) {
var stuff;
if(item == null) {
item = IWDatacapture.getRootItems();
}
for(var i = 0; i < item.length; i++) {
alert("stuff: " + item.getName() + " type: " + item.getType() + " item count: " + i + " total items: " + item.length);
if(item.getType() == "select" && item.getName().match(/brand$/)) {
stuff = "stuff";
alert("matched!");
break;
}
else {
if(item.getChildren() != null && item.getChildren() != "" ){
getBrandValue(item.getChildren());
}
}
}
alert("stuff: " + stuff);
}
When I printed out every single item getting processed, it looks like the corret match is made in the if block and
break is breaking out of the first tab (because there are a few other items after the
brand item. However, it progresses into the 2nd tab and then after the last item is printed out in the alert, I see 4 extra alerts for "stuff : undefined".
I've tried various ways of trying to exit out of the for loop, like explicitly setting a label for the for loop, and setting break to that, but it was not working and keeps looping.
Any ideas?