simplekolecalc/kole.html
vv01f 200e9b5a11 add simple solution
da frlan darum bat, zur weiteren Verwendung
2023-03-28 01:12:30 +02:00

38 lines
1.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<style>
input[type='number']{text-align:right;}
</style>
</head>
<body>
<p>Bei Eingaben werden Komma und Punkt als Dezimaltrennzeichen betrachtet.</p>
<table>
<tr><td>Berechne:</td><td><input type="radio" name="b" value="k" id="bk" class="bb" checked="checked" /><label for="bk">KoLe</label><input type="radio" name="b" value="e" id="be" class="bb" /><label for="be">Einnahmen</label></td></tr>
<tr><td>Einnahme</td><td><input type="number" step="0.01" id="e" value="1"/> €</td></tr>
<tr><td>Umsatzsteuer</td><td><input type="number" step="0.01" id="u" value="19"/>%</td></tr>
<tr><td>Entropieumlage</td><td><input type="number" step="0.01" id="z" value="23"/>%</td></tr>
<tr><td>KoLe</td><td><input type="number" step="0.01" id="k" value=""/> €</td></tr>
<tr><td>&nbsp;</td><td><input value="Berechnen" id="b" type="button"/></td></tr>
</table>
<script>
var e=document.getElementById('e');
var u=document.getElementById('u');
var z=document.getElementById('z');
var k=document.getElementById('k');
var bk=document.getElementById('bk');
var be=document.getElementById('be');
var b = document.getElementById("b");
b.addEventListener("click", function(){
if(bk.checked){
k.value = Math.round( parseFloat(e.value.replace(/,/g, '.')) / ( 1 + parseFloat(u.value.replace(/,/g, '.')) / 100 ) * ( 1 - parseFloat(z.value.replace(/,/g, '.')) / 100 ) * 100 ) / 100;
}else// if(be.checked)
{
e.value = Math.round( parseFloat(k.value.replace(/,/g, '.')) * ( 1 + parseFloat(u.value.replace(/,/g, '.')) / 100 ) / ( 1 - parseFloat(z.value.replace(/,/g, '.')) / 100 ) * 100 ) / 100;
}
});
</script>
</body>
</html>