This is created for project cost calculation in 2008. Note that it does not use jQuery, but using $ symbol. Be careful to use it with jQuery on the same web page. JavaScript component: he.calc.js //TODO: validation logic /* This component is created specifically for Excel like calculation. Author: Albert He Created: 2008-12-01 usage: He.enableTrace = true; // default = false, if true read on developer console default dataType: number default precision: 2 //accept external event handler onSelfChange //value changed by self, arg = the cell object onchange //value changed by any reason, arg = the cell object dataType: 'string' 'number' precision: 3 validation: 100 */ var doc = document; var $ = function(id) { return document.getElementById(id); }; var removeLeadingZero = function(numberString) { return (numberString.indexOf('0') == 0) ? numberString.replace(/^[0]*/, '') : numberString; } var v = function(id) { var value = ''; var elm = $(id); if (!elm) return 0; if (elm.cellInstance) value = elm.cellInstance.value; else { He.log += elm.id + ' has no instance (has not been defined yet).\n'; //this indicates using undefined cell. //alert(elm.id + ' value: ' + elm.value); } if (value == '') value = 0; return eval(value); }; function roundTo(base, precision) { var n = Math.pow(10, precision); return Math.round(base * n) / n; } function numberPrecision(base, precision) { if (precision == 999) return base-0; else if (precision <= 0) return Math.round(base); var s = roundTo(base, precision).toString(); var decimalIndex = s.indexOf("."); if (precision > 0 && decimalIndex < 0) { decimalIndex = s.length; s += '.'; } while (decimalIndex + precision + 1 > s.length) {…