Skip to main content

How to create a calculator using HTML, CSS & JavaScript

Create a Calculator Using HTML ,CSS & JavaScript

How to create a calculator using HTML, CSS & JavaScript


Source :

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Dynamic Calculator</title>
<style>
body
{
background:#ecf0f1;
font-family:arial;
}
#calBody
{
padding:10px;
background:#3498db;
width:300px;
height:310px;
margin:auto;
top:0px;
right:0px;
left:0px;
bottom:0px;
position:absolute;
-webkit-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15);
-moz-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15);
box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.15);
}
#calBody h1
{
color:#ecf0f1;
font-weight:normal;
text-align:center;
}
#calBody input, #answer
{
padding:10px; width:270px;
border:none;
margin:auto;
display:block;
margin-bottom:10px;
font-size:24px;
color:#34495e;
background:#ecf0f1;
}
#buttons
{
width:230px;
margin:auto;
}
#buttons button
{
height:50px;
width:50px;
border:none;
background:#34495e;
margin:2px;
font-size:24px;
color:#ecf0f1;
}
#buttons button:hover
{
background:#CF000F;
}
</style>
</head>
<body>
<div id="calBody">
        <h1>Dynamic Calculator</h1>
        <input type="number" min="0" id="num1">
            <input type="number" min="0" id="num2">
            <div id="answer">
            0
            </div>
            <div id="buttons">
            <button onClick="addition()">+</button>
                <button onClick="subus()">-</button>
                <button onClick="multi()">x</button>
                <button onClick="devi()">/</button>
            </div>
        </div>
     
        <script>
function addition()
{
var num1 = parseInt(document.getElementById("num1").value);
var num2 = parseInt(document.getElementById("num2").value);
var ans = num1+num2
document.getElementById('answer').innerHTML = ans;
}
function subus()
{
var num1 = parseInt(document.getElementById("num1").value);
var num2 = parseInt(document.getElementById("num2").value);
var ans = num1-num2
document.getElementById('answer').innerHTML = ans;
}
function multi()
{
var num1 = parseInt(document.getElementById("num1").value);
var num2 = parseInt(document.getElementById("num2").value);
var ans = num1*num2
document.getElementById('answer').innerHTML = ans;
}
function devi()
{
var num1 = parseInt(document.getElementById("num1").value);
var num2 = parseInt(document.getElementById("num2").value);
var ans = num1/num2
document.getElementById('answer').innerHTML = ans;
}
</script>
</body>
</html>


Output : 




Comments

Popular posts from this blog

Windows all version product key free

Product key for window vista : Vista | Ultimate | Acer | 3YDB8-YY3P4-G7FCW-GJMPG-VK48C Vista | Ultimate | Advent | 39MVW-K8KKQ-BGJ9B-24PMW-RYQMV Vista | Ultimate | Alienware | 7QVFM-MF2DT-WXJ62-XTYX3-P9YTT Vista | Ultimate | Asus | 6F2D7-2PCG6-YQQTB-FWK9V-932CC Vista | Ultimate | Dell | 2QBP3-289MF-9364X-37XGX-24W6P Vista | Ultimate | DixonsXP | 6JPQR-4G364-2B7P7-83FXW-DR8QC Vista | Ultimate | Gateway | 6P8XK-GDDTB-X9PJQ-PYF36-G8WGV Vista | Ultimate | Hedy | 7R2C3-DWCBG-C8G96-MPT8T-K37C7 Vista | Ultimate | HP | 23CM9-P7MYR-VFWRT-JGH7R-R933G Vista | Ultimate | Lenovo | 24J6Q-YJJBG-V4K4Q-2J8HY-8HBQQ Vista | Ultimate | OQO | C4QGV-XHYYT-9PW8R-DCFTQ-FBD6M Vista | Ultimate | Toshiba | 33G3W-JY3XQ-CQQ7C-TG96R-R6J6Q Vista | Ultimate | Sony | 2KKTK-YGJKV-3WMRR-3MDQW-TJP47 Vista | Ultimate | Stone | GVV4P-RQXD7-X9XKB-M2G9H-C93VM Vista | Ultimate | Velocity Micro | 9BKKK-7Y888-MHD67-HHXTB-332K9 Vista | Business | Acer | 2TJTJ-C72D7-7BCYH-FV3HT-JGD4F Vista | Bus...

How to Create a secure login panel with PHP & Mysql using parameters and session

Secure Login with PHP & Mysql Download project zip Requirement: you need an Apache and MySQL Server database on your device If your computer has xampp or wamp or mamp  or lamp that's great otherwise you need to install Apache and MySQL server Create a database login Run this query : CREATE TABLE admin ( id INT(6) AUTO_INCREMENT PRIMARY KEY, uname VARCHAR(30) NOT NULL, upass VARCHAR(30) NOT NULL ); INSERT INTO `admin` (`id`, `uname`, `upass`) VALUES (NULL, 'admin', 'admin1993'); That means you set your username =  admin and password = admin1993 Login Page: login.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>Login Getway</title> <link rel="stylesheet" href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css" type="text/css"> <style> * { margin:0px; padding:0px; font-family:ar...

Which HTML Element helps to SEO Score up viewing result without boost by search engines

Here we discuss SEO and SEO friendly tags in HTML Add caption Meta tags: <meta charset="UTF-8"> <meta name="description" content="Here you can write your website descripsions"> <meta name="keywords" content="here you can write your description and all tahte sapareted by comma like (key1, key2, kay3)"> <meta name="author" content="Here you write website's authers name"> Headline tag: <h1>Headline tag 1</h1> <h2>Headline tag 1</h2> <h3>Headline tag 1</h3> This tag is most importent tag in website for SEO. Use H1 tag in wevery page of your website. its helps to identify content  Attribute : ALT This attribute used to find image form search engine. in this tag, you have to use for your website and type the title of the image. like  <img src="address.jpg" alt="title of your image">   TITLE This attribut...