Calculate payments with JavaScript