Advertisement
azunyashka

Untitled

Feb 5th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
  6. <title>Simple Calculator</title>
  7. </head>
  8. <body>
  9. <script type="text/javascript">
  10. function Go() {
  11. var first = +(document.getElementById('FirstNumber').value);
  12. var second = +(document.getElementById('SecondNumber').value);
  13. var action = document.getElementById('Action').value;
  14. var res;
  15. alert(res);
  16. alert(action);
  17. switch (action) {
  18. case 'sum' :
  19. res == +first + +second;
  20. break;
  21. case 'minus' :
  22. res == +first - +second;
  23. break;
  24. case 'multi' :
  25. res == +first * +second;
  26. break;
  27. case 'div' :
  28. res == +first / +second;
  29. break;
  30. default :
  31. alert('error');
  32. }
  33. alert(res);
  34. alert(action);
  35.  
  36.  
  37. }
  38. </script>
  39. <input type="text" value="0" name="first">
  40. <input type="text" value="0" name="second">
  41. <p>
  42. <input type="radio" value="sum" name="action"> Сумма
  43. <input type="radio" value="minus" name="action"> Вычитание
  44. <input type="radio" value="multi" name="action"> Умножение
  45. <input type="radio" value="div" name="action"> Деление
  46. </p>
  47. <input type="button" value="Go" id="Go" onclick="Go()" >
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement