Calcul
How do I make an calcul?
What is a calcul? How do you make a calcul? This script and codes were developed by Fred Hawk on 14 November 2022, Monday.
Calcul - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Calcul</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <section class="calculator"> <section class="header"> <h1 class="title">Code calculator</h1> </section> <form name="calc"> <div class="display-wrapper"> <input type="text" name="previous" class="display"> <input type="text" name="display" class="display"> </div> <div class="row"> <input type="button" name="seven" id="" value="7" onclick="calc.display.value+='7'" /> <input type="button" name="eight" id="" value="8" onclick="calc.display.value+='8'" /> <input type="button" name="nine" id="" value="9" onclick="calc.display.value+='9'" /> <input type="button" name="divide" id="" value="÷" onclick="calc.display.value+='/'" /> </div> <div class="row"> <input type="button" name="four" id="" value="4" onclick="calc.display.value+='4'" /> <input type="button" name="five" id="" value="5" onclick="calc.display.value+='5'" /> <input type="button" name="six" id="" value="6" onclick="calc.display.value+='6'" /> <input type="button" name="times" id="" value="×" onclick="calc.display.value+='*'" /> </div> <div class="row"> <input type="button" name="one" id="" value="1" onclick="calc.display.value+='1'" /> <input type="button" name="two" id="" value="2" onclick="calc.display.value+='2'" /> <input type="button" name="three" id="" value="3" onclick="calc.display.value+='3'" /> <input type="button" name="minus" id="" value="-" onclick="calc.display.value+='-'" /> </div> <div class="row"> <input type="button" name="clear" id="" value="C" onclick="clearCalc()" /> <input type="button" name="zero" id="" value="0" onclick="calc.display.value+='0'" /> <input type="button" name="deci" id="" value="." onclick="calc.display.value+='.'" /> <input type="button" name="plus" id="" value="+" onclick="calc.display.value+='+'" /> </div> <div class="row"> <input type="button" name="equals" id="equals" value="=" onclick="makeResult()" /> </div> </form> </section>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Calcul - Script Codes CSS Codes
body { font-size: 16px;
}
h1 { font-size: 1.5em; margin: 0.2em; padding: 0.2em;
}
input[type=button] { width: 2.5em; height: 2.3em; border-radius: 5px; background: #AEAEAE;
}
.container { margin-top: 3em; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
.calculator { background: #18a1f5; padding: 1em; width: 200px; border-radius: 10px; box-shadow: 4px 4px 4px #888;
}
.display-wrapper { background: #eeeeee; border-radius: 5px;
}
.display { border: none; border: 0; margin-left: 5px; background: #eeeeee; width: 83%; height: 30px; border-radius: 5px; color: black; font-size: 1.3em; padding: 0 10px; text-align: right;
}
.row { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; padding: 0.3em;
}
#equals { width: 100%;
}
Calcul - Script Codes JS Codes
// TO DO
// #1 check so there is only 1 decimal point.
// #2 don't allow leading zeros except when a decimal point is after
// #3 if display is empty, equals should use clear() Done!
// #4 when pressing equals it should store the result in a second display above and in a variable. Done!
// #5 prevent equals from adding number to upper display without a math operator as the first character if there is allready a number in the upper display
// #6 prevent so when you press an operator button 2 or more times in a row it add them all to the equation, but instead replaces the one that is allready there.
var result = "";
var prevres = "";
function makeResult() { if (calc.previous.value == "" && calc.display.value == "") { clearCalc(); } else { if (calc.previous.value == "") { result = eval(calc.display.value); calc.previous.value = result; calc.display.value = ""; prevres = result; result = ""; } else { prevres += calc.display.value; prevres = eval(prevres); calc.previous.value = prevres; calc.display.value = ""; } }
}
function clearCalc() { calc.display.value = ""; calc.previous.value = ""; prevres = ""; result = "";
}
Developer | Fred Hawk |
Username | osycon |
Uploaded | November 14, 2022 |
Rating | 3 |
Size | 3,248 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Weekly UI - ToDo mobile design | 5,967 Kb |
CSS Flexbox 3 col example | 3,013 Kb |
Weekly UI - Paypal Navigation | 9,240 Kb |
Weekly UI - Stripe - Pricing section | 5,848 Kb |
Lilli | 6,117 Kb |
Weekly UI - Dropbox Hero Component | 3,811 Kb |
Pomodoro Clock | 3,705 Kb |
Weekly UI - Invisionapp Sign up | 4,382 Kb |
Weather App | 4,171 Kb |
A Pen by Fred Hawk | 2,201 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Bezier Animation with straight paths | Rhernando | 2,087 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
SCSS Unit Conversion | Jakob-e | 8,210 Kb |
Slides-07-1 POSITION | Exhtml | 1,909 Kb |
A form arranged using automatic placement. | Vikasford | 2,103 Kb |
A Pen by Stan Williams | Stanssongs | 6,706 Kb |
Find The Penguin | Lelder | 2,212 Kb |
Codero Sitemap | S1m0ne | 28,169 Kb |
Loading Bar | Jaradlight | 2,333 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!