First, you don't have any elements in your example which would be affected by your script and show the practical outcome. So I added two elements in the snippet below which have those IDs, the second one having the "hidden" class.
Second, use select.value
in your condition instead of just select
And as a third step, I'd suggest to only use one class (in my snippet the "hidden" class) and toggle the display
parameter with that - if it's removed, the element will have the default block
display.
And last, CSS rules for classes need to have a dot in front of the class name to be valid class selectors.
select.onchange = function() {
if (select.value == "Firma") {
$('#osoba_fizyczna').toggleClass('hidden');
$('#firma').toggleClass('hidden');
} else {
$('#firma').toggleClass('hidden');
$('#osoba_fizyczna').toggleClass('hidden');
}
}
.hidden {
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="select">
<option value="właściciel serwisu będący osobą fizyczną -">osoba fizyczna</option>
<option value="Firma">firma</option>
</select>
<div id="firma" class="hidden">This is the "firma" element</div>
<div id="osoba_fizyczna">This is the "osoba_fizyczna" element</div>
And actually, with just two option values you could write the function a lot simpler:
select.onchange = function() {
$('#osoba_fizyczna, #firma').toggleClass('hidden');
}
.hidden {
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="select">
<option value="właściciel serwisu będący osobą fizyczną -">osoba fizyczna</option>
<option value="Firma">firma</option>
</select>
<div id="firma" class="hidden">This is the "firma" element</div>
<div id="osoba_fizyczna">This is the "osoba_fizyczna" element</div>