jsCalc (based on jAutoCalc) is a lightweight JavaScript library for performing automatic calculations based on input values in a web page. This library is designed to replace the functionality of a jQuery-based script, providing a modern and dependency-free alternative.
- Automatic calculations based on input values.
- Support for various mathematical functions (sum, average, min, max, count, etc.).
- Customizable formatting options for result display.
- Smart handling of integers and decimals.
- Easy integration into your web page.
-
Include the jsCalc script in your HTML file:
<script src="path/to/jsCalc.js"></script>
-
Add the jsCalc attribute to the HTML elements where you want automatic calculations:
<input type="text" name="field1" jsCalc="sum({field2} * 2)"> <input type="text" name="field2">
-
Initialize jsCalc in your JavaScript:
document.addEventListener('DOMContentLoaded', function () {
document.querySelector('body').jsCalc();
});