Simple Calculation
About this app
A simple web app for performing calculations
Simple Calculation Simple Calculation Number 1 Number 2 Calculate Result
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Simple Calculation</title>
<meta name="description" content="A simple web app for performing calculations">
<meta name="keywords" content="simple, calculation, math, web app">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Get the input elements
var num1Input = document.getElementById("num1");
var num2Input = document.getElementById("num2");
var resultInput = document.getElementById("result");
// Add event listener to the calculate button
var calculateBtn = document.getElementById("calculateBtn");
calculateBtn.addEventListener("click", function() {
var num1 = parseFloat(num1Input.value);
var num2 = parseFloat(num2Input.value);
var result = num1 + num2;
resultInput.value = result;
});
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
<style>
/* App CSS Goes Here */
body {
background-color: #f0f0f0;
font-family: 'Open Sans', sans-serif;
}
.container {
max-width: 400px;
margin: 0 auto;
padding-top: 100px;
}
h1 {
text-align: center;
color: #333;
}
.form-group {
margin-bottom: 20px;
}
.form-control {
height: 40px;
}
.btn {
width: 100%;
}
.result {
margin-top: 20px;
text-align: center;
font-size: 24px;
font-weight: 600;
color: #333;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Simple Calculation</h1>
<div class="form-group">
<label for="num1">Number 1</label>
<input type="number" id="num1" class="form-control" placeholder="Enter number 1">
</div>
<div class="form-group">
<label for="num2">Number 2</label>
<input type="number" id="num2" class="form-control" placeholder="Enter number 2">
</div>
<button id="calculateBtn" class="btn btn-primary">Calculate</button>
<div class="form-group">
<label for="result">Result</label>
<input type="text" id="result" class="form-control" readonly>
</div>
<div id="result" class="result"></div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!