[thelist] recursive JS function?

Erik Mattheis gozz at gozz.com
Tue Feb 20 01:17:23 CST 2001


At 11:36 PM -0800 2/19/01, Joshua OIson wrote:
>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;
>}

Right ... something like that ... this is it, I've been staring at it 
for quite some time, wondering if it could ever fall for a guy like 
me:

function contributeToPage() {
	var theResult = '';
	theResult += this.returnMyFormFields();
	for (var i=0; i < this.theItems.length; i++) {
		theResult += this.theItems[i].contributeToPage();
		}
	return theResult;
}

Thanks for the help, Joshua and Ben.
-- 
- Erik Mattheis
http://gozz.com/
(612) 827 3963




More information about the thelist mailing list