BC466Part VIBonus Chapterscorresponding to one of the periods. (Web host sites)
BC466Part VIBonus Chapterscorresponding to one of the periods. Each period also has three properties (a period ID, forecast sales, and actual sales). Thus, the salesproperty is an array of objects. function getOneSalesRep(i) { var oneRecord = new Object(); var oneElem = xDoc.getElementsByTagName( salesrep )[i]; oneRecord.id = oneElem.getElementsByTagName( employeeid )[0].firstChild.data; var contactInfoElem = oneElem.getElementsByTagName( contactinfo )[0]; oneRecord.firstName = contactInfoElem.getElementsByTagName( firstname )[0].firstChild.data; oneRecord.lastName = contactInfoElem.getElementsByTagName( lastname )[0].firstChild.data; oneRecord.eMail = contactInfoElem.getElementsByTagName( email )[0].firstChild.data; oneRecord.phone = contactInfoElem.getElementsByTagName( phone )[0].firstChild.data; oneRecord.fax = contactInfoElem.getElementsByTagName( fax )[0].firstChild.data; oneRecord.manager = new Object(); var oneMgrElem = oneElem.getElementsByTagName( manager )[0]; oneRecord.manager.id = oneMgrElem.getElementsByTagName( employeeid )[0].firstChild.data; oneRecord.manager.firstName = oneMgrElem.getElementsByTagName( firstname )[0].firstChild.data; oneRecord.manager.lastName = oneMgrElem.getElementsByTagName( lastname )[0].firstChild.data; oneRecord.region = oneElem.getElementsByTagName( region )[0].firstChild.data; oneRecord.sales = new Array(); var allPeriods = oneElem.getElementsByTagName( salesrecord )[0].childNodes; var temp; var accumForecast = 0, accumActual = 0; for (var i = 0; i < allPeriods.length; i++) { if (allPeriods[i].nodeType == 1) { temp = new Object(); temp.period = allPeriods[i].getElementsByTagName( id )[0].firstChild.data; temp.forecast = parseInt(allPeriods[i].getElementsByTagName( forecast )[0].firstChild.data); temp.actual = parseInt(allPeriods[i].getElementsByTagName( actual )[0].firstChild.data); temp.quotaPct = getPercentage(temp.actual, temp.forecast); oneRecord.sales[temp.period] = temp; accumForecast += temp.forecast; accumActual += temp.actual; } } oneRecord.totalForecast = accumForecast; oneRecord.totalActual = accumActual; oneRecord.totalQuotaPct = getPercentage(accumActual, accumForecast); return oneRecord; } function getPercentage(actual, forecast) { var pct = (actual/forecast * 100) + ; pct = pct.match(/d*.d/); return parseFloat(pct); }