willemvo
New Member
- Messages
- 19
- Reaction score
- 0
- Points
- 0
i dunno what i did wrong,,, can anybody help me?
THANKS A LOT
Code:
<html>
<head><title>TEST</title>
<script type="text/javascript" language="JavaScript1.3">
/*i'm dutch so maybe there will be some terms you don't get!!*/
function plusje(form) {
document.getElementById("number").disabled=true;
document.getElementById("sign").value='+';
}
function minnetje(form) {
document.getElementById("number").disabled=true;
document.getElementById("sign").value='-';
}
function keertje(form) {
document.getElementById("number").disabled=true;
document.getElementById("sign").value='X';
}
function deeltje(form) {
document.getElementById("number").disabled=true;
document.getElementById("sign").value='/';
}
function resetje(form) {
document.getElementById("number").disabled=false;
document.getElementById("number").value='1';
document.getElementById("sign").value='';
document.getElementById("number2").disabled=false;
document.getElementById("number2").value='2';
}
function bereken(form) {
var sign = document.getElementById("sign").value;
if (sign == '+')
{
erbij();
}
else if (sign == '-')
{
eraf()
}
else if (sign == 'X')
{
keren()
}
else if (sign == '/')
{
delen()
}
else
{
alert ("Fill in a sign!!")
}
}
function erbij() {
var number1 = document.getElementById("number").value;
var number2 = document.getElementById("number2").value;
var answer = number1 + number2;
var result = document.getElementById("result");
result.innerHTML = '';
result.innerHTML += answer;
if (answer > 100000 || answer < -100000)
{
alert ("ERROR: number is too big or too small!!");
}
}
function eraf() {
var number1 = document.getElementById("number").value;
var number2 = document.getElementById("number2").value;
var answer = number1 - number2;
var result = document.getElementById("result");
result.innerHTML = '';
result.innerHTML += answer;
if (answer > 100000 || answer < -100000)
{
alert ("ERROR: number is too big or too small!!");
}
}
function keren() {
var number1 = document.getElementById("number").value;
var number2 = document.getElementById("number2").value;
var answer = number1 * number2;
var result = document.getElementById("result");
result.innerHTML = '';
result.innerHTML += answer;
if (answer > 100000 || answer < -100000)
{
alert ("ERROR: number is too small or too big!!");
}
}
function delen() {
var number1 = document.getElementById("number").value;
var number2 = document.getElementById("number2").value;
var answer = number1 / number2;
var result = document.getElementById("result");
result.innerHTML = '';
result.innerHTML += answer;
if (answer > 100000 || anser < -100000)
{
alert ("ERROR: number is too small or too small!!!!");
}
}
</script>
</head>
<body>
<form name="form">
<input type="text" value="1" name="number1" id="number" />
<input type="text" size="1" value="" id="sign" style="border:0;" name="sign" readonly />
<input type="text" value="1" name="number2" id="number2" /> = <div id="result"></div>
<br>
<hr />
<input type="button" value="+" name="plus" onClick="plusje(this.form);" />
<input type="button" value="-" name="min" onClick="minnetje(this.form)" />
<input type="button" value="X" name="product" onClick="keertje(this.form)" />
<input type="button" value="/" name="divide" onClick="deeltje(this.form)" />
<br>
<hr />
<input type="button" value="OPNIEUW" name="opnieuw" id="opnieuw" onClick="resetje(this.form);" />
<br>
<hr />
<input type="button" value="bereken" name="bereken" onClick="bereken(this.form)" />
</form>
</body>
</html>