I want my labels to appear in one row the one that are in "form".
For now they are on under other. But at the same time I want the box where the result is showing to be under every label.
Also the title which is on green background I want it to be in the middle of the div "box".
And how to write the result in pop out window?
<div class="box">
<div class="title">Kalkulator podatków</div>
<div class="text">
<h1>Pensja brutto</h1>
<input type="number" id="liczba">
<label for="stany"><h2>Wybierz województwo:</h2></label>
<select name="stany" id="stany">
<option value="" selected disabled>Wybierz województwo</option>
<option value="Mazowieckie">Mazowieckie</option>
<option value="Łódzkie">Łódzkie</option>
<option value="Pomorskie">Pomorskie</option>
<option value="Śląsk">Śląsk</option>
</select>
</div>
<hr>
<br><br>
<p id="wynik"></p>
<br><br>
<form>
<label for="wp">Wielkość podatku:</label>
<input type="text" id="wp" disabled>
<br><br>
<label for="pn">Pensja netto:</label>
<input type="text" id="pn" disabled>
</form>
<div class="button">
<button id="oblicz" onclick="Count()">Oblicz</button>
<button id="reset" onclick="Reset()">Reset</button>
</div>
</div>
<script>
function Count() {
var bruttoInput = document.getElementById("liczba");
var wojewodztwoSelect = document.getElementById("stany");
var wpInput = document.getElementById("wp");
var pnInput = document.getElementById("pn");
var wynikParagraph = document.getElementById("wynik");
var brutto = parseFloat(bruttoInput.value);
var wojewodztwo = wojewodztwoSelect.value;
var stawkiPodatkowe = {
"Mazowieckie": 0.2,
"Łódzkie": 0.18,
"Pomorskie": 0.22,
"Śląsk": 0.19
};
if (stawkiPodatkowe.hasOwnProperty(wojewodztwo)) {
var stawkaPodatkowa = stawkiPodatkowe[wojewodztwo];
var podatek = brutto * stawkaPodatkowa;
var netto = brutto - podatek;
wpInput.value = podatek.toFixed(2);
pnInput.value = netto.toFixed(2);
wynikParagraph.innerHTML = "";
} else {
wynikParagraph.innerHTML = "Nieprawidłowe województwo. Podatek nie może być obliczony.";
wpInput.value = "";
pnInput.value = "";
}
}
function Reset() {
document.getElementById("liczba").value ="";
document.getElementById("stany").value = "";
document.getElementById("w`your text`p").value ="";
document.getElementById("pn").value ="";
}
</script>
6
Answers
<br>
I didn’t do anything about anything on a green background, as your code had nothing on a green background