Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/html">
- <head>
- <meta charset="UTF-8">
- <title>Zadaca 1</title>
- <script src="jquery-3.1.1.js"></script>
- </head>
- <body>
- <script>
- $(document).ready(function() {
- var a = parseInt($("#a").val());
- var b = parseInt($("#b").val());
- var r;
- if ($("#plus").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(a + b);
- });
- }
- if ($("#minus").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(a - b);
- });
- }
- if ($("#mnoz").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(a * b);
- });
- }
- if ($("#del").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(a/b);
- });
- }
- if ($("#sin").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").html(Math.sin(a));
- });
- }
- if ($("#cos").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(Math.cos(a));
- });
- }
- if ($("#tg").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(Math.tan(a));
- });
- }
- if ($("#cel").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(Math.floor(a));
- });
- }
- if ($("#stepen").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(Math.pow(a,b));
- });
- }
- if ($("#koren").is(":checked")) {
- $("button").click(function () {
- $("#rezultat").text(Math.sqrt(a));
- });
- }
- });
- </script>
- <h1>Калкулатор</h1>
- <div>
- <div style="text-align: left;float: left">
- <p id="p0">a<input id="a" style="width: 15px">
- b <input id="b" style="width: 15px"></p>
- <p id="p1">
- <input id="plus" type="radio" name="oper" checked>a+b
- <input id="minus" type="radio" name="oper">a-b
- <input id="mnoz" type="radio" name="oper">a*b
- <input id="del" type="radio" name="oper">a/b
- <br>
- <input id="sin" type="radio" name="oper" >sin(a)
- <input id="cos" type="radio" name="oper">cos(a)
- <input id="tg" type="radio" name="oper">tg(a)
- <br>
- <input id="cel" type="radio" name="oper"d>[a]
- <input id="stepen" type="radio" name="oper">a<sup>b</sup>
- <input id="koren" type="radio" name="oper">√<span style="text-decoration: overline">a</span>
- </p>
- <button id="bt1">Пресметај</button>
- <p id="rezultat"></p>
- </div>
- </div>
- <br>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement