Advertisement
ProjcheskiF1

Калкулатор ИП

Dec 8th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 3.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/html">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Zadaca 1</title>
  6.     <script src="jquery-3.1.1.js"></script>
  7. </head>
  8. <body>
  9. <script>
  10.  
  11.     $(document).ready(function() {
  12.         var a = parseInt($("#a").val());
  13.         var b = parseInt($("#b").val());
  14. var r;
  15.         if ($("#plus").is(":checked")) {
  16.             $("button").click(function () {
  17.                 $("#rezultat").text(a + b);
  18.             });
  19.  
  20.         }
  21.         if ($("#minus").is(":checked")) {
  22.             $("button").click(function () {
  23.                 $("#rezultat").text(a - b);
  24.             });
  25.  
  26.         }
  27.         if ($("#mnoz").is(":checked")) {
  28.             $("button").click(function () {
  29.                 $("#rezultat").text(a * b);
  30.             });
  31.  
  32.         }
  33.         if ($("#del").is(":checked")) {
  34.             $("button").click(function () {
  35.                 $("#rezultat").text(a/b);
  36.             });
  37.  
  38.         }
  39.         if ($("#sin").is(":checked")) {
  40.             $("button").click(function () {
  41.                 $("#rezultat").html(Math.sin(a));
  42.             });
  43.  
  44.         }
  45.         if ($("#cos").is(":checked")) {
  46.             $("button").click(function () {
  47.                 $("#rezultat").text(Math.cos(a));
  48.             });
  49.  
  50.         }
  51.         if ($("#tg").is(":checked")) {
  52.             $("button").click(function () {
  53.                 $("#rezultat").text(Math.tan(a));
  54.             });
  55.  
  56.         }
  57.         if ($("#cel").is(":checked")) {
  58.             $("button").click(function () {
  59.                 $("#rezultat").text(Math.floor(a));
  60.             });
  61.  
  62.         }
  63.         if ($("#stepen").is(":checked")) {
  64.             $("button").click(function () {
  65.                 $("#rezultat").text(Math.pow(a,b));
  66.             });
  67.  
  68.         }
  69.         if ($("#koren").is(":checked")) {
  70.             $("button").click(function () {
  71.                 $("#rezultat").text(Math.sqrt(a));
  72.             });
  73.  
  74.         }
  75.     });
  76. </script>
  77.  
  78.  
  79. <h1>Калкулатор</h1>
  80. <div>
  81.     <div style="text-align: left;float: left">
  82.         <p id="p0">a<input id="a" style="width: 15px">
  83.         b <input id="b" style="width: 15px"></p>
  84.         <p id="p1">
  85.             <input id="plus" type="radio" name="oper" checked>a+b
  86.             <input id="minus" type="radio" name="oper">a-b
  87.             <input id="mnoz" type="radio" name="oper">a*b
  88.             <input id="del" type="radio" name="oper">a/b
  89. <br>
  90.             <input id="sin" type="radio" name="oper" >sin(a)
  91.             <input id="cos" type="radio" name="oper">cos(a)
  92.             <input id="tg" type="radio" name="oper">tg(a)
  93. <br>
  94.             <input id="cel" type="radio" name="oper"d>[a]
  95.             <input id="stepen" type="radio" name="oper">a<sup>b</sup>
  96.             <input id="koren" type="radio" name="oper">&radic;<span style="text-decoration: overline">a</span>
  97.  
  98.         </p>
  99.         <button id="bt1">Пресметај</button>
  100.         <p id="rezultat"></p>
  101.  
  102.  
  103.  
  104.     </div>
  105.  
  106.  
  107.  
  108. </div>
  109.  
  110. <br>
  111. </body>
  112. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement