|
-
Nov 22nd, 2000, 06:45 PM
#1
Thread Starter
Fanatic Member
here is my code
+++++++++++++++++++++++++++++
<HTML>
<HEAD>
</HEAD>
<BODY onLoad="javascript:add();">
<SCRIPT LANGUAGE="JavaScript">
<!--
correct=0;
wrong=0;
function random(maxValue) {
day= new Date();
hour= day.getHours();
min=day.getMinutes();
sec=day.getSeconds();
mili=day.getTime()
return(((hour*3600)+(min*60)+(sec)+mili) % maxValue);
}
function ranom(maxValue) {
day= new Date();
mil=day.getTime();
return((mil) % maxValue);
}
function add()
{
maxValue=100;
numA=random(maxValue);
numB=ranom(maxValue);
numC=numA + numB;
document.write ("type the correct answer" + numA + "+" + numB + "=") ;
document.write ("<center><form name=FrmAdder><input name='txtNum' size='5'><br><input type='button' value='add' onClick='newwin.ans();'></form></center>");
return true;
}
function ans()
{
alert("hello")
if (Answer == numC) {
correct++;
msg = "Congratulations, your answer is correct.";
}
else {
wrong++;
msg = "Oops! " + Answer + " is incorrect.\n\n"
+ "The correct answer was " +numC + ".";
}
score = "" + ((correct / (correct + wrong)) * 100);
score = score.substring(0,4) + "%";
alert(msg + "\n\nYOUR SCORE: " + score + "\n"
+ correct + " correct\n"
+ wrong + " incorrect")
}
// -->
</script>
</BODY>
</HTML>
+++++++++++++++++++++++++++++++
this pops up in a new browser and generates two random numbers and a text box and a submit button.
when the user clicks the enter button it should call the ans() funtion. but it doesn't.
any suggestions??
anyone??
strangly when I view the source of this in IE i only get the document.write code.but in Netscape I get all the code you see upabove.
???????????????
thanks for any help from anyone!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|