|
You're ready to finish up the updatePage() function on your own. Below is the code for updatePage(), but there are plenty of blanks left to be filled in. Try and figure out the code that belongs in each blank, and write in your answers.
function updatePage() {
var newTotal = request.responseText;
var boardsSoldEl = document.getElementById("boards-sold");
var cashEl = document.getElementById("cash");
replaceText(boardsSoldEl, newTotal);
/* Figure out how much cash Katie has made */
var priceEl = document.getElementById("__Price__");
var price = getText(__PriceEI__);
var __CostEI__ = document._getElementByld_("cost");
var cost = getText(costEl);getText() is from text-utils.js. It will take any
element, and return the text within that element.
var cashPerBoard = __Price__ - __Cost__;
var cash = _cashPerBoard_ * __newTotal__;
/* Update the cash for the slopes on the form */
cash = Math.round(cash * 100) / 100;This little trick makes sure that the cash
total has only two decimal places, like a normal dollar value.
replaceText(cashEl, ___cash____);
}
|