Comprehensive Length Unit Converter
Info
Created On: July 28, 2023
Created By:
Tags
AI
Model: chatgpt-plugin
Time: 0 seconds
Prompt Tokens: 0
Completion Tokens: 0
Total Token Cost: 0
Get This App On Your Website
Copy Code
1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.
Javascript, HTML, CSS Code
Copy
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>
<title>Comprehensive Length Unit Converter</title>
<style>
body {font-family: Arial, sans-serif;}
.container {max-width: 70%; margin: 0 auto; padding: 20px;}
input[type='number'] {width: 100%; padding: 10px; margin: 10px 0;}
select {width: 100%; padding: 10px; margin: 10px 0;}
button {width: 100%; padding: 10px; background-color: #4CAF50; color: white; border: none;}
button:hover {background-color: #45a049;}
</style>
<link rel="canonical" href="https://calculator.tools/prompt/2465/">
<meta charset="utf-8">
</head>
<body>
<div class='container'>
<h1>Comprehensive Length Unit Converter</h1>
<label for='inputValue'>Enter the length:</label>
<input type='number' id='inputValue' placeholder='Enter the length...'>
<label for='inputUnit'>From:</label>
<select id='inputUnit'>
<option value='millimeter'>Millimeter</option>
<option value='centimeter'>Centimeter</option>
<option value='meter'>Meter</option>
<option value='kilometer'>Kilometer</option>
<option value='inch'>Inch</option>
<option value='foot'>Foot</option>
<option value='yard'>Yard</option>
<option value='mile'>Mile</option>
<option value='nauticalMile'>Nautical Mile</option>
<option value='gaz'>Gaz</option>
<option value='acre'>Acre</option>
<option value='kanal'>Kanal</option>
<option value='marla'>Marla</option>
<option value='murabba'>Murabba</option>
<option value='biswa'>Biswa</option>
<option value='killa'>Killa</option>
</select>
<label for='outputUnit'>To:</label>
<select id='outputUnit'>
<option value='millimeter'>Millimeter</option>
<option value='centimeter'>Centimeter</option>
<option value='meter'>Meter</option>
<option value='kilometer'>Kilometer</option>
<option value='inch'>Inch</option>
<option value='foot'>Foot</option>
<option value='yard'>Yard</option>
<option value='mile'>Mile</option>
<option value='nauticalMile'>Nautical Mile</option>
<option value='gaz'>Gaz</option>
<option value='acre'>Acre</option>
<option value='kanal'>Kanal</option>
<option value='marla'>Marla</option>
<option value='murabba'>Murabba</option>
<option value='biswa'>Biswa</option>
<option value='killa'>Killa</option>
</select>
<button onclick='convert()'>Convert</button>
<h2 id='output'></h2>
</div>
<script>
// Conversion rates to meter
const conversionRates = {
'millimeter': 0.001,
'centimeter': 0.01,
'meter': 1,
'kilometer': 1000,
'inch': 0.0254,
'foot': 0.3048,
'yard': 0.9144,
'mile': 1609.34,
'nauticalMile': 1852,
'gaz': 0.9144,
'acre': 4046.85642,
'kanal': 505.857552,
'marla': 25.2928776,
'murabba': 101171.5104,
'biswa': 2023.430208,
'killa': 4046.870416
};
function convert() {
let inputValue = document.getElementById('inputValue').value;
let inputUnit = document.getElementById('inputUnit').value;
let outputUnit = document.getElementById('outputUnit').value;
let outputValue = inputValue * conversionRates[inputUnit] / conversionRates[outputUnit];
document.getElementById('output').innerHTML = inputValue + ' ' + inputUnit + ' = ' + outputValue.toFixed(2) + ' ' + outputUnit;
}
</script>
<script type="text/javascript"> var localStoragePrefix = "ct-{{ cachebreaker }}"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>