I have a function that checkes the value of a checkbox and changes it you click on the checkbox. The value has to change from 0 to 1. This problem occures with every checkbox and I can't find any information to help me. click on the checkbox the console prints out "Uncaught TypeError: teVoet is not a function at HTMLInputElement.onclick (deelEen.php:152)"
this is html code
<!-- Vervoer -->
<legend><span class="section">10</span>Vervoer</legend>
<p>Hoe komt de leerling naar school</p>
<p><input type="checkbox" value="0" name="teVoet" onclick="teVoet()" ID="teVoet" /> Te voet</p>
<p><input type="checkbox" value="0" name="fiets" onclick="fiets()" ID="fiets" /> Fiets</p>
<p><input type="checkbox" value="0" name="motorfiets" onclick="motorfiets()" ID="motorfiets" /> Motorfiets</p>
<p><input type="checkbox" value="0" name="bus" onclick="bus()" ID="bus" /> Bus</p>
<p>
Buzzypas
<select name="buzzypas">
<option value="nee">Nee</option>
<option value="ja">Ja</option>
</select>
</p>
<p><input type="checkbox" value="0" name="trein" onclick="trein()" ID="trein" /> Trein</p>
<p>abonnement voor traject <input type="text" name="traject" /></p>
<p><input type="checkbox" value="0" name="auto" onclick="auto()" ID="auto" /> Auto</p>
And this is my javascript code
//scripts deelEen.php
function teVoet() {
if (document.getElementById("teVoet").value == 0) {
document.getElementById("teVoet").value = 1;
} else {
document.getElementById("teVoet").value = 0;
}
}
function fiets() {
if (document.getElementById("fiets").value == 0) {
document.getElementById("fiets").value = 1;
} else {
document.getElementById("fiets").value = 0;
}
}
function motorfiets() {
if (document.getElementById("motorfiets").value == 0) {
document.getElementById("motorfiets").value = 1;
} else {
document.getElementById("motorfiets").value = 0;
}
}
function bus() {
if (document.getElementById("bus").value == 0) {
document.getElementById("bus").value = 1;
} else {
document.getElementById("bus").value = 0;
}
}
function trein() {
if (document.getElementById("trein").value == 0) {
document.getElementById("trein").value = 1;
} else {
document.getElementById("trein").value = 0;
}
}
function auto() {
if (document.getElementById("auto").value == 0) {
document.getElementById("auto").value = 1;
} else {
document.getElementById("auto").value = 0;
}
}
Aucun commentaire:
Enregistrer un commentaire