1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // отправка с уведомлением//
- <head>
- <h1>CalcLive</h1>
- </head>
- <body>
- <div>
- <input id="testimony1" type="number" size="12" placeholder="0" />//вносим показания старта периода//<br>
- <input id="testimony2" type="number" size="12" placeholder="0" />//вносим показания учета на конец
- периода//<br>
- <input id="tarif" type="number" size="12" placeholder="0" />//вводим тариф на услугу//<br>
- <input id="startbalance" type="number" size="12" placeholder="0" />//вводим баланс на старте
- периода//<br>
- <!--<button onclick="debetCalculationOnClick()"> //нажимаем на кнопку для расчета//
- DEBET Calc
- </button>-->
- <br><br>
- <div id="calc" style="display: inline-block;color:greenyellow;"></div>
- <script>
- const debetCalculation = (testimony1, testimony2, tarif, startbalance) =>
- result = startbalance - (testimony2 - testimony1) * tarif;
- const debetCalculationOnClick = () => {
- testimony1Val = parseFloat(testimony1.value);
- testimony2Val = parseFloat(testimony2.value);
- tarifVal = parseFloat(tarif.value);
- startbalanceVal = parseFloat(startbalance.value);
- result = debetCalculation(testimony1Val, testimony2Val, tarifVal, startbalanceVal);
- calc = document.getElementById('calc');
- calc.innerHTML = result.toString();
- if (result > 0) {
- calc.style.backgroundColor = 'green';
- calc.innerHTML = "Total Amount: " + calc.innerHTML;
- }
- else if (isNaN(result))
- calc.innerHTML = "";
- else {
- calc.style.backgroundColor = 'red';
- }
- }
- testimony1.oninput = debetCalculationOnClick;
- testimony2.oninput = debetCalculationOnClick;
- tarif.oninput = debetCalculationOnClick;
- startbalance.oninput = debetCalculationOnClick;
- </script>
- </div>
- </body>
|