Flächen umrechner
Rechnet die eingegebene Fläche in anderen Flächeneinheiten aus.
Dies ist ein
Älterer JavaScript Code mit unnötigen langen Javascript Code. Läuft aber.
Wer Lust hat, kann es ja mal versuchen, den Code kürzer zu erstellen.
Man nennt auch Codegolf.
Der aktuelle Code ist 16867 Bytes groß (Zeichen).
Ich schätze mal das es auch unter 3000 klappen könnte.
Wer Lust hat, kann gerne bei der Challenge teilnehmen
Der hier verwendete Code
<script>
function convertFlache(Ausgangswert2){
if (Ausgangswert2 === 'nm'){
var inp = document.getElementById('nm').value;
var szw = inp.replace(',','.')
document.getElementById('um').value = parseFloat(szw) * 0.000001;
document.getElementById('mm').value = parseFloat(szw) * 0.000000000001;
document.getElementById('cm').value = parseFloat(szw) * 0.00000000000001;
document.getElementById('dm').value = parseFloat(szw) * 0.0000000000000001;
document.getElementById('m').value = parseFloat(szw) * 0.000000000000000001;
document.getElementById('km').value = parseFloat(szw) * 0.000000000000000000000001;
document.getElementById('ft').value = parseFloat(szw) * 0.00000000000000001076391041671;
document.getElementById('inch').value = parseFloat(szw) * 0.0000000000000015500031000062;
document.getElementById('yd').value = parseFloat(szw) * 0.0000000000000000011959900463011;
document.getElementById('rd').value = parseFloat(szw) * 0.00000000000000000003953686103475;
document.getElementById('mi').value = parseFloat(szw) * 0.0000000000000000000000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.00000000000000000001;
document.getElementById('ha').value = parseFloat(szw) * 0.0000000000000000000001;
}
if (Ausgangswert2 === 'um'){
var inp = document.getElementById('um').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 1000000;
document.getElementById('mm').value = parseFloat(szw) * 0.000001;
document.getElementById('cm').value = parseFloat(szw) * 0.00000001;
document.getElementById('dm').value = parseFloat(szw) * 0.0000000001;
document.getElementById('m').value = parseFloat(szw) * 0.000000000001;
document.getElementById('km').value = parseFloat(szw) * 0.000000000000000001;
document.getElementById('ft').value = parseFloat(szw) * 0.00000000001076391041671;
document.getElementById('inch').value = parseFloat(szw) * 0.0000000015500031000062;
document.getElementById('yd').value = parseFloat(szw) * 0.0000000000011959900463011;
document.getElementById('rd').value = parseFloat(szw) * 0.00000000000003953686103475;
document.getElementById('mi').value = parseFloat(szw) * 0.0000000000000000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.00000000000001;
document.getElementById('ha').value = parseFloat(szw) * 0.0000000000000001;
}
if (Ausgangswert2 === 'mm'){
var inp = document.getElementById('mm').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 1000000000000;
document.getElementById('um').value = parseFloat(szw) * 1000000;
document.getElementById('cm').value = parseFloat(szw) * 0.01;
document.getElementById('dm').value = parseFloat(szw) * 0.0001;
document.getElementById('m').value = parseFloat(szw) * 0.000001;
document.getElementById('km').value = parseFloat(szw) * 0.000000000001;
document.getElementById('ft').value = parseFloat(szw) * 0.00001076391041671;
document.getElementById('inch').value = parseFloat(szw) * 0.001550003100006;
document.getElementById('yd').value = parseFloat(szw) * 0.000001195990046301;
document.getElementById('rd').value = parseFloat(szw) * 0.00000003953686103474;
document.getElementById('mi').value = parseFloat(szw) * 0.0000000000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.00000001;
document.getElementById('ha').value = parseFloat(szw) * 0.0000000001;
}
if (Ausgangswert2 === 'cm'){
var inp = document.getElementById('cm').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 100000000000000;
document.getElementById('um').value = parseFloat(szw) * 100000000;
document.getElementById('mm').value = parseFloat(szw) * 100;
document.getElementById('dm').value = parseFloat(szw) * 0.01;
document.getElementById('m').value = parseFloat(szw) * 0.0001;
document.getElementById('km').value = parseFloat(szw) * 0.0000000001;
document.getElementById('ft').value = parseFloat(szw) * 0.001076391041671;
document.getElementById('inch').value = parseFloat(szw) * 0.1550003100006;
document.getElementById('yd').value = parseFloat(szw) * 0.0001195990046301;
document.getElementById('rd').value = parseFloat(szw) * 0.000003953686103475;
document.getElementById('mi').value = parseFloat(szw) * 0.00000000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.000001;
document.getElementById('ha').value = parseFloat(szw) * 0.00000001;
}
if (Ausgangswert2 === 'dm'){
var inp = document.getElementById('dm').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 10000000000000000;
document.getElementById('um').value = parseFloat(szw) * 10000000000;
document.getElementById('mm').value = parseFloat(szw) * 10000;
document.getElementById('cm').value = parseFloat(szw) * 100;
document.getElementById('m').value = parseFloat(szw) * 0.01;
document.getElementById('km').value = parseFloat(szw) * 0.00000001;
document.getElementById('ft').value = parseFloat(szw) * 0.1076391041671;
document.getElementById('inch').value = parseFloat(szw) * 15.50003100006;
document.getElementById('yd').value = parseFloat(szw) * 0.01195990046301;
document.getElementById('rd').value = parseFloat(szw) * 0.0003953686103475;
document.getElementById('mi').value = parseFloat(szw) * 0.000000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.0001;
document.getElementById('ha').value = parseFloat(szw) * 0.000001;
}
if (Ausgangswert2 === 'm'){
var inp = document.getElementById('m').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 1000000000000000000;
document.getElementById('um').value = parseFloat(szw) * 1000000000000;
document.getElementById('mm').value = parseFloat(szw) * 1000000;
document.getElementById('cm').value = parseFloat(szw) * 10000;
document.getElementById('dm').value = parseFloat(szw) * 100;
document.getElementById('km').value = parseFloat(szw) * 0.000001;
document.getElementById('ft').value = parseFloat(szw) * 10.76391041671;
document.getElementById('inch').value = parseFloat(szw) * 1550.003100006;
document.getElementById('yd').value = parseFloat(szw) * 1.195990046301;
document.getElementById('rd').value = parseFloat(szw) * 0.03953686103475;
document.getElementById('mi').value = parseFloat(szw) * 0.0000003861021585424;
document.getElementById('a').value = parseFloat(szw) * 0.01;
document.getElementById('ha').value = parseFloat(szw) * 0.0001;
}
if (Ausgangswert2 === 'km'){
var inp = document.getElementById('km').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 1000000000000000000000000;
document.getElementById('um').value = parseFloat(szw) * 1000000000000000000;
document.getElementById('mm').value = parseFloat(szw) * 1000000000000;
document.getElementById('cm').value = parseFloat(szw) * 10000000000;
document.getElementById('dm').value = parseFloat(szw) * 100000000;
document.getElementById('m').value = parseFloat(szw) * 1000000;
document.getElementById('ft').value = parseFloat(szw) * 10763910.41671;
document.getElementById('inch').value = parseFloat(szw) * 1550003100.006;
document.getElementById('yd').value = parseFloat(szw) * 1195990.046301;
document.getElementById('rd').value = parseFloat(szw) * 39536.86103475;
document.getElementById('mi').value = parseFloat(szw) * 0.3861021585424;
document.getElementById('a').value = parseFloat(szw) * 10000;
document.getElementById('ha').value = parseFloat(szw) * 100;
}
if (Ausgangswert2 === 'ft'){
var inp = document.getElementById('ft').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 92903040000000000;
document.getElementById('um').value = parseFloat(szw) * 92903040000;
document.getElementById('mm').value = parseFloat(szw) * 92903.04;
document.getElementById('cm').value = parseFloat(szw) * 929.0304;
document.getElementById('dm').value = parseFloat(szw) * 9.290304;
document.getElementById('m').value = parseFloat(szw) * 0.09290304;
document.getElementById('km').value = parseFloat(szw) * 0.00000009290304;
document.getElementById('inch').value = parseFloat(szw) * 144;
document.getElementById('yd').value = parseFloat(szw) * 0.1111111111111;
document.getElementById('rd').value = parseFloat(szw) * 0.003673094582186;
document.getElementById('mi').value = parseFloat(szw) * 0.00000003587006427916;
document.getElementById('a').value = parseFloat(szw) * 0.0009290304;
document.getElementById('ha').value = parseFloat(szw) * 0.000009290304;
}
if (Ausgangswert2 === 'inch'){
var inp = document.getElementById('inch').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 645160000000000;
document.getElementById('um').value = parseFloat(szw) * 645160000;
document.getElementById('mm').value = parseFloat(szw) * 645.16;
document.getElementById('cm').value = parseFloat(szw) * 6.4516;
document.getElementById('dm').value = parseFloat(szw) * 0.064516;
document.getElementById('m').value = parseFloat(szw) * 0.00064516;
document.getElementById('km').value = parseFloat(szw) * 0.00000000064516;
document.getElementById('ft').value = parseFloat(szw) * 0.006944444444444;
document.getElementById('yd').value = parseFloat(szw) * 0.0007716049382716;
document.getElementById('rd').value = parseFloat(szw) * 0.00002550760126518 ;
document.getElementById('mi').value = parseFloat(szw) * 0.0000000002490976686052;
document.getElementById('a').value = parseFloat(szw) * 0.0000064516;
document.getElementById('ha').value = parseFloat(szw) * 0.000000064516;
}
if (Ausgangswert2 === 'yd'){
var inp = document.getElementById('yd').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 836127360000000000;
document.getElementById('um').value = parseFloat(szw) * 836127360000;
document.getElementById('mm').value = parseFloat(szw) * 836127.36;
document.getElementById('cm').value = parseFloat(szw) * 8361.2736;
document.getElementById('dm').value = parseFloat(szw) * 83.612736;
document.getElementById('m').value = parseFloat(szw) * 0.83612736;
document.getElementById('km').value = parseFloat(szw) * 0.00000083612736;
document.getElementById('ft').value = parseFloat(szw) * 9;
document.getElementById('inch').value = parseFloat(szw) * 1296;
document.getElementById('rd').value = parseFloat(szw) * 0.03305785123967 ;
document.getElementById('mi').value = parseFloat(szw) * 0.0000003228305785124;
document.getElementById('a').value = parseFloat(szw) * 0.0083612736;
document.getElementById('ha').value = parseFloat(szw) * 0.000083612736;
}
if (Ausgangswert2 === 'mi'){
var inp = document.getElementById('mi').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 2589988110336000000000000;
document.getElementById('um').value = parseFloat(szw) * 2589988110336000000;
document.getElementById('mm').value = parseFloat(szw) * 2589988110336;
document.getElementById('cm').value = parseFloat(szw) * 25899881103.36;
document.getElementById('dm').value = parseFloat(szw) * 258998811.0336;
document.getElementById('m').value = parseFloat(szw) * 2589988.110336;
document.getElementById('km').value = parseFloat(szw) * 2.589988110336;
document.getElementById('ft').value = parseFloat(szw) * 27878400;
document.getElementById('inch').value = parseFloat(szw) * 4014489600;
document.getElementById('rd').value = parseFloat(szw) * 102400 ;
document.getElementById('yd').value = parseFloat(szw) * 3097600;
document.getElementById('a').value = parseFloat(szw) * 25899.88110336;
document.getElementById('ha').value = parseFloat(szw) * 258.9988110336;
}
if (Ausgangswert2 === 'rd'){
var inp = document.getElementById('rd').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 25292852640000000000;
document.getElementById('um').value = parseFloat(szw) * 25292852640000;
document.getElementById('mm').value = parseFloat(szw) * 25292852.64;
document.getElementById('cm').value = parseFloat(szw) * 252928.5264;
document.getElementById('dm').value = parseFloat(szw) * 2529.285264;
document.getElementById('m').value = parseFloat(szw) * 25.29285264;
document.getElementById('km').value = parseFloat(szw) * 0.00002529285264;
document.getElementById('ft').value = parseFloat(szw) * 272.25;
document.getElementById('inch').value = parseFloat(szw) * 39204;
document.getElementById('mi').value = parseFloat(szw) * 0.000009765625 ;
document.getElementById('yd').value = parseFloat(szw) * 30.25;
document.getElementById('a').value = parseFloat(szw) * 0.2529285264;
document.getElementById('ha').value = parseFloat(szw) * 0.002529285264;
}
if (Ausgangswert2 === 'a'){
var inp = document.getElementById('a').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 100000000000000000000;
document.getElementById('um').value = parseFloat(szw) * 100000000000000;
document.getElementById('mm').value = parseFloat(szw) * 100000000;
document.getElementById('cm').value = parseFloat(szw) * 1000000;
document.getElementById('dm').value = parseFloat(szw) * 10000;
document.getElementById('m').value = parseFloat(szw) * 100;
document.getElementById('km').value = parseFloat(szw) * 0.0001;
document.getElementById('ft').value = parseFloat(szw) * 1076.391041671;
document.getElementById('inch').value = parseFloat(szw) * 155000.3100006;
document.getElementById('mi').value = parseFloat(szw) * 0.00003861021585424 ;
document.getElementById('yd').value = parseFloat(szw) * 119.5990046301;
document.getElementById('rd').value = parseFloat(szw) * 3.953686103475;
document.getElementById('ha').value = parseFloat(szw) * 0.01;
}
if (Ausgangswert2 === 'ha'){
var inp = document.getElementById('ha').value;
var szw = inp.replace(',','.')
document.getElementById('nm').value = parseFloat(szw) * 10000000000000000000000;
document.getElementById('um').value = parseFloat(szw) * 10000000000000000;
document.getElementById('mm').value = parseFloat(szw) * 10000000000;
document.getElementById('cm').value = parseFloat(szw) * 100000000;
document.getElementById('dm').value = parseFloat(szw) * 1000000;
document.getElementById('m').value = parseFloat(szw) * 10000;
document.getElementById('km').value = parseFloat(szw) * 0.01;
document.getElementById('ft').value = parseFloat(szw) * 107639.1041671;
document.getElementById('inch').value = parseFloat(szw) * 15500031.00006;
document.getElementById('mi').value = parseFloat(szw) * 0.003861021585424 ;
document.getElementById('yd').value = parseFloat(szw) * 11959.90046301;
document.getElementById('rd').value = parseFloat(szw) * 395.3686103475;
document.getElementById('a').value = parseFloat(szw) * 100;
}
}
</script>
<form>
<div class="table-scrollable">
<table border=0 cellpadding=1 cellspacing=0 >
<tr><td>nm²</td><td><input type="number" name="nm" id="nm" onchange="convertFlache('nm');"></td></tr>
<tr><td>µm²</td><td><input type="number" name="µm" id="um" onchange="convertFlache('um');"></td></tr>
<tr><td>mm²</td><td><input type="number" name="mm" id="mm" onchange="convertFlache('mm');"></td></tr>
<tr><td>cm²</td><td><input type="number" name="cm" id="cm" onchange="convertFlache('cm');"></td></tr>
<tr><td>dm²</td><td><input type="number" name="dm" id="dm" onchange="convertFlache('dm');"></td></tr>
<tr><td>m²</td><td><input type="number" name="m" id="m" onchange="convertFlache('m');"></td></tr>
<tr><td>km²</td><td><input type="number" name="km" id="km" onchange="convertFlache('km');"></td></tr>
<tr><td>inch²</td><td><input type="number" name="inch" id="inch" onchange="convertFlache('inch');"></td></tr>
<tr><td>ft²</td><td><input type="number" name="ft" id="ft" onchange="convertFlache('ft');"></td></tr>
<tr><td>yd²</td><td><input type="number" name="yd" id="yd" onchange="convertFlache('yd');"></td></tr>
<tr><td>rd²</td><td><input type="number" name="rd" id="rd" onchange="convertFlache('rd');"></td></tr>
<tr><td>mi²</td><td><input type="number" name="mi" id="mi" onchange="convertFlache('mi');"></td></tr>
<tr><td>a</td><td><input type="number" name="a" id="a" onchange="convertFlache('a');"></td></tr>
<tr><td>ha</td><td><input type="number" name="ha" id="ha" onchange="convertFlache('ha');"></td></tr>
</table>
</div>
</form>