6.8. Just Do ItIt's time to put everything you've learned so far into action. Below is the updatePage() callback function for the Boards app. To finish the code up, you'll need to use what you've learned about asynchronous requests, the DOM, XML, and dynamic HTML. function updatePage() { if (request.readyState == 4) { if (request.status == 200) { // Get the updated totals from the XML response var xmlDoc = request._____________; var xmlBoards = _______._____________________("boards-sold")[0]; var totalBoards = xmlBoards.firstChild.nodeValue; var xmlBoots = _______._____________________("boots-sold")[0]; var totalBoots = xmlBoots.firstChild.nodeValue; var xmlBindings = _______._____________________("___________")___; var totalBindings = xmlBindings.firstChild.nodeValue; // Update the page with new totals var boardsSoldEl = document.________________("boards-sold"); var bootsSoldEl = document.________________("boots-sold"); var bindingsSoldEl = document.________________("bindings-sold"); var cashEl = document.________________("cash"); replaceText(______________, _______________); replaceText(______________, _______________); replaceText(______________, _________________); // Figure out how much cash Katie has made on boards var boardsPriceEl = document.getElementById("______________"); var boardsPrice = getText(boardsPriceEl); var boardsCostEl = document.getElementById("_____________"); var boardsCost = getText(boardsCostEl); var cashPerBoard = boardsPrice - boardsCost; var cash = cashPerBoard * totalBoards; // Figure out how much cash Katie has made on boots var bootsPriceEl = ____________.getElementById("boots-price"); var bootsPrice = getText(____________); var bootsCostEl = ____________.getElementById("boots-cost"); var bootsCost = getText(____________); var cashPerBoot = ____________ - ____________; cash = ________ + (cashPerBoot * totalBoots); // Figure out how much cash Katie has made on bindings __________________________________________ __________________________________________ __________________________________________ __________________________________________ __________________________________________ __________________________________________ __________________________________________ __________________________________________ You're on your own here, but this shouldn't be any problem for you at this stage of the game. // Update the cash for the slopes on the web form cash = Math.round(cash * 100) / 100; replaceText(cashEl, cash); } else alert("Error! Request status is " + request.status); } } |