flare1028us
06-23-2004, 12:16 AM
Hey all
I have been asked to write a js prog/util for an after-school program at my church. It's pretty simple: just read the problem, type in the answer,
and click a button to see if it's right.
My problem is this:
I have written the basic structure for this prog the way I always have,
except now it's not working. I ran it through the netscape javascript console
and I got the following error:
function eval()
{
if (document.ans.2t2.value="4");
alert("Correct");
}
Missing ) after condition.
I cannot see what is wrong with this script.
I feel kind of dumb b/c conditons are usually very easy and I never have
problems with them.
Here is my full souce:
<html>
<head>
<script language="javascript">
function eval()
{
if (document.ans.2t2.value =="4") ;
alert("2x2=4. Correct.");
}
</script>
</head>
<body>
<form name="ans">
2x2 <input type="textarea" name="2t2"><br>
<input type="button" value="Eval" onclick="eval()"></form>
</body>
</html>
Can anyone see what is wrong with this script?
Any help is appreciated.
Carl
I have been asked to write a js prog/util for an after-school program at my church. It's pretty simple: just read the problem, type in the answer,
and click a button to see if it's right.
My problem is this:
I have written the basic structure for this prog the way I always have,
except now it's not working. I ran it through the netscape javascript console
and I got the following error:
function eval()
{
if (document.ans.2t2.value="4");
alert("Correct");
}
Missing ) after condition.
I cannot see what is wrong with this script.
I feel kind of dumb b/c conditons are usually very easy and I never have
problems with them.
Here is my full souce:
<html>
<head>
<script language="javascript">
function eval()
{
if (document.ans.2t2.value =="4") ;
alert("2x2=4. Correct.");
}
</script>
</head>
<body>
<form name="ans">
2x2 <input type="textarea" name="2t2"><br>
<input type="button" value="Eval" onclick="eval()"></form>
</body>
</html>
Can anyone see what is wrong with this script?
Any help is appreciated.
Carl