[thelist] recursive JS function?
Joshua OIson
joshua at alphashop.net
Mon Feb 19 23:28:37 CST 2001
You might try something like this:
function getProp(obj, propName)
{
for(i in obj.returnMyProperties_Array())
{
if (i == propName) return obj[i];
}
for(i in obj.childItems)
{
var temp = getProp(i,propName);
if (temp) return temp;
}
return null;
}
You may need to define a childItems method which returns an array of all
children to an item and you will also need a function, here named
returnMyProperties_Array that returns the properties in an array, where the
index is the property name and the value is the value, such as so:
var myItemProps = new Array();
myItemProps['name'] = 'hurst';
myItemProps['size'] = 'small';
myItemProps['year'] = '1972';
myItemProps['color'] = 'black';
If you have any questions, or I left out something important, just buzz me
back.
Good luck,
-joshua
More information about the thelist
mailing list