body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.converter {
max-width: 400px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.input-group {
display: flex;
margin-bottom: 20px;
}
input[type="number"],
select {
flex: 1;
padding: 10px;
font-size: 16px;
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#result {
text-align: center;
font-size: 18px;
font-weight: bold;
color: #007bff;
}
function convert() {
const inputValue = parseFloat(document.getElementById('inputValue').value);
const fromUnit = document.getElementById('fromUnit').value;
const toUnit = document.getElementById('toUnit').value;
let result;
if (fromUnit === 'm' && toUnit === 'km') {
result = inputValue / 1000;
} else if (fromUnit === 'm' && toUnit === 'cm') {
result = inputValue * 100;
} else if (fromUnit === 'm' && toUnit === 'inch') {
result = inputValue * 39.3701;
} else if (fromUnit === 'm' && toUnit === 'ft') {
result = inputValue * 3.28084;
} else if (fromUnit === 'km' && toUnit === 'm') {
result = inputValue * 1000;
} else if (fromUnit === 'km' && toUnit === 'cm') {
result = inputValue * 100000;
} else if (fromUnit === 'km' && toUnit === 'inch') {
result = inputValue * 39370.1;
} else if (fromUnit === 'km' && toUnit === 'ft') {
result = inputValue * 3280.84;
} else if (fromUnit === 'cm' && toUnit === 'm') {
result = inputValue / 100;
} else if (fromUnit === 'cm' && toUnit === 'km') {
result = inputValue / 100000;
} else if (fromUnit === 'cm' && toUnit === 'inch') {
result = inputValue / 2.54;
} else if (fromUnit === 'cm' && toUnit === 'ft') {
result = inputValue / 30.48;
} else if (fromUnit === 'inch' && toUnit === 'm') {
result = inputValue * 0.0254;
} else if (fromUnit === 'inch' && toUnit === 'km') {
result = inputValue * 0.0000254;
} else if (fromUnit === 'inch' && toUnit === 'cm') {
result = inputValue * 2.54;
} else if (fromUnit === 'inch' && toUnit === 'ft') {
result = inputValue * 0.0833333;
} else if (fromUnit === 'ft' && toUnit === 'm') {
result = inputValue * 0.3048;
} else if (fromUnit === 'ft' && toUnit === 'km') {
result = inputValue * 0.0003048;
} else if (fromUnit === 'ft' && toUnit === 'cm') {
result = inputValue * 30.48;
} else if (fromUnit === 'ft' && toUnit === 'inch') {
result = inputValue * 12;
} else {
result = inputValue; // Same unit
}
document.getElementById('result').innerText = `${inputValue} ${fromUnit} is equal to ${result.toFixed(2)} ${toUnit}`;
}
Free Units Converter Tools NEW 2024 Best Free Unit Converters to Use in 2024
Reviewed by want call girls and call boy at home
on
February 06, 2024
Rating: 5
No comments: