Calculator Web
Calculator Web
DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Byte Converter</title>
</head>
<body>
<h1>Byte Converter</h1>
<form>
<label for="bytes">Bytes:</label>
<input type="number" id="bytes" name="bytes" oninput="convertBytes()"
onchange="convertBytes()" value="0"><br>
<label for="kilobytes">Kilobytes:</label>
<input type="number" id="kilobytes" name="kilobytes"
oninput="convertKilobytes()" onchange="convertKilobytes()" value="0"><br>
<label for="megabytes">Megabytes:</label>
<input type="number" id="megabytes" name="megabytes"
oninput="convertMegabytes()" onchange="convertMegabytes()" value="0"><br>
<label for="gigabytes">Gigabytes:</label>
<input type="number" id="gigabytes" name="gigabytes"
oninput="convertGigabytes()" onchange="convertGigabytes()" value="0"><br>
</form>
<script>
function convertBytes() {
// Get input value
var bytes = document.getElementById("bytes").value;
// Calculate values
var kilobytes = bytes / 1024;
var megabytes = kilobytes / 1024;
var gigabytes = megabytes / 1024;
function convertKilobytes() {
// Get input value
var kilobytes = document.getElementById("kilobytes").value;
// Calculate values
var bytes = kilobytes * 1024;
var megabytes = kilobytes / 1024;
var gigabytes = megabytes / 1024;
function convertMegabytes() {
// Get input value
var megabytes = document.getElementById("megabytes").value;
// Calculate values
var kilobytes = megabytes * 1024;
var bytes = kilobytes * 1024;
var gigabytes = megabytes / 1024;
function convertGigabytes() {
// Get input value
var gigabytes = document.getElementById("gigabytes").value;
// Calculate values
var megabytes = gigabytes * 1024;
var kilobytes = megabytes * 1024;
var bytes = kilobytes * 1024;
document.getElementById("megabytes").value = megabytes;
}
</script>
</body>
</html>