calc_func.html 988 B

123456789101112131415161718192021222324252627282930313233343536
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Calc Live</title>
  8. </head>
  9. <body>
  10. <input type='number' id="cost" placeholder="Cost of pack of cigarettes"/>
  11. <input type='number' id="amount" placeholder="Amount of cigarettes in pack"/>
  12. <input type='number' id="amountDay" placeholder="Smooking cigarettes in day"/>
  13. <div id="price">
  14. otvet
  15. </div>
  16. <div id="month">
  17. текст в div
  18. </div>
  19. <script>
  20. const calcPrice = () =>
  21. price.innerHTML = cost.value / amount.value ;
  22. cost.oninput = amount.oninput = calcPrice;
  23. const calcMonth = () =>
  24. month.innerHTML = cost.value / amount.value * amountDay.value;
  25. amountDay.oninput = calcMonth;
  26. </script>
  27. </body>
  28. </html>