Advertisement
Guest User

Calculator-math-io

a guest
Feb 23rd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Функция подсчета. Вешается на кнопку '='.
  3. function solve () {
  4.     var equation = document.getElementById('out').value;
  5.     document.getElementById('out').value = eval(equation);
  6. }
  7.  
  8.  
  9. // Функции ввода чисел. Вешаются на соответствующие кнопки
  10. function first () { document.getElementById('out').value += '1'; }
  11. function second (){ document.getElementById('out').value += '2'; }
  12. function third () { document.getElementById('out').value += '3'; }
  13. function fourth (){ document.getElementById('out').value += '4'; }
  14. function fifth () { document.getElementById('out').value += '5'; }
  15. function sixth () { document.getElementById('out').value += '6'; }
  16. function seventh(){ document.getElementById('out').value += '7'; }
  17. function eight () { document.getElementById('out').value += '8'; }
  18. function ninth () { document.getElementById('out').value += '9'; }
  19.  
  20.  
  21. // Функции ввода математических операторов. Вешаются на соответствующие кнопки
  22. function adding (){ document.getElementById('out').value += '+'; }
  23. function minus () { document.getElementById('out').value += '-'; }
  24. function delenie(){ document.getElementById('out').value += '/'; }
  25. function multply(){ document.getElementById('out').value += '*'; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement