Trying to make a function that works when the checkbox is checked

<div id="dolny">
<h2>Ile będzie kosztowało moje wesele?</h2>
<label for="a">Podaj liczbę gości:</label> <input type="number" id="lgosci"> <br>
<label for="a">Wesele z poprawinami?</label><input type="checkbox" id="poprawiny"> <br>
<input type="button" id="przycisk" onclick="suma()" value="Oblicz koszt">
</br>
<p>
<div id="koszt"></div>
</p>
</div>
<script type="text/javascript">

function suma(){

var a = document.getElementById("lgosci").value;
var b = document.getElementById("poprawiny");

If(b.checked){
	var cena = a * 100
	document.getElementById("koszt").innerHTML = cena;
}

}

</script>

I’m quite new to all this and I’m pretty confused right now.

as stupid as it sounds, the answer to your problem is don’t capitalize the if.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.