Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
- <title>Simple Calculator</title>
- </head>
- <body>
- <script type="text/javascript">
- function Go() {
- var first = +(document.getElementById('FirstNumber').value);
- var second = +(document.getElementById('SecondNumber').value);
- var action = document.getElementById('Action').value;
- var res;
- alert(res);
- alert(action);
- switch (action) {
- case 'sum' :
- res == +first + +second;
- break;
- case 'minus' :
- res == +first - +second;
- break;
- case 'multi' :
- res == +first * +second;
- break;
- case 'div' :
- res == +first / +second;
- break;
- default :
- alert('error');
- }
- alert(res);
- alert(action);
- }
- </script>
- <input type="text" value="0" name="first">
- <input type="text" value="0" name="second">
- <p>
- <input type="radio" value="sum" name="action"> Сумма
- <input type="radio" value="minus" name="action"> Вычитание
- <input type="radio" value="multi" name="action"> Умножение
- <input type="radio" value="div" name="action"> Деление
- </p>
- <input type="button" value="Go" id="Go" onclick="Go()" >
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement