Reputation: 5
I came across a problem with javascript, it keeps on coming with a uncaught reference error: voeruit not define.
It's a different language, because i'm dutch.
I hope that somebody will spot the problem, I'm just starting so I need to learn what to do with these kind of problems
function reset()
{
var fout1object = document.getElementById('fout1').innerHTML;
var fout2object = document.getElementById('fout2').innerHTML;
var fout3object = document.getElementById('fout3').innerHTML;
var foutje = false
fout1object = "";
fout2object = "";
fout3object = "";
}
function foutcontrole1(foutje)
{
var invoer = Number(document.getElementById('invoer1').value);
var datum = new Date();
var foutobject = document.getElementById('fout1').innerHTML;
var jaar = datum.getFullYear();
if( isNaN(invoer) )
{
foutobject ="moet getal zijn"
document.getElementById("fout1").innerHTML = foutobject;
foutje = true;
}
else
{
if(invoer < 1911)
{
foutobject ="Bouwjaar moet boven 1910 zijn";
document.getElementById("fout1").innerHTML = foutobject;
foutje = true;
}
else
{
if(invoer >= jaar)
{
foutobject ="Jaartal moet lager zijn dan of gelijk aan " + datum.getFullYear();
document.getElementById("fout1").innerHTML = foutobject;
foutje = true;
}
}
}
function foutcontrole2(foutje)
{
var invoer = Number(document.getElementById('invoer2').value);
var foutobject = document.getElementById('fout2').innerHTML;
if( isNaN(invoer) )
{
foutobject ="moet een getal zijn";
document.getElementById("fout2").innerHTML = foutobject;
foutje = true;
}
else
{
if(invoer < 1000)
{
foutobject="De nieuwprijs moet minimaal 1000 euro zijn";
document.getElementById("fout2").innerHTML = foutobject;
foutje = true;
}
}
}
function berekenen()
{
uitkomst = 100;
window.alert(uitkomst)
}
function voeruit()
{
var foutje = false;
reset();
foutcontrole1(foutje);
foutcontrole2(foutje);
if( !foutje )
{
berkenen();
}
return false;
}
<body>
<tr>
<td valign="top">
<form onsubmit="javascript:return voeruit();">
<table summary="">
<tr>
<td>nieuw prijs</td>
<td><input id="invoer2" value="" /></td>
<td id="fout2"><td>
</tr>
<tr>
<td>bouwjaar</td>
<td><input id="invoer1" value="" /></td>
<td id="fout1"><td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td valign="top">
<button onclick="javascript:voeruit();">Voer uit</button>
</td>
</tr>
<p id="uitkomst"></p>
</table>
</body>
Upvotes: 1
Views: 98
Reputation: 3397
Your javascript is invalid - function foutcontrole1(foutje)
had no closing bracket, you should add another one }
before function berekenen()
Upvotes: 1