I seem to be having a problem with some code I’ve written, and I can’t seem to figure it out. I’m trying to make an online study tool for a friend of mine, but it’s not running correctly. Any help would be truly appreciated. Here’s the code:
<html>
<head>
<title>
Practice Page
</title>
<script type=”text/javascript”>
function checkAnswer(kAnswer, cAnswer){
if (kAnswer == cAnswer){
alert(“Woohoo! Yay! Go Kyara!!!”);
} else {
alert(“Look at it again!”);
}
}
function clearAll(){
document.response.answer.value = “”;
}
function generate(max,op){
var num1;
var num2;
var num3;
var total;
var ans;
var ph;
ph = max/2;
num1 = Math.floor(Math.random()*max)-ph;
num2 = Math.floor(Math.random()
num3 = Math.floor(Math.random()*max)-ph;
document.write(“<div class=’problemBubble’>”);
if(op == a){
total = num1 + num2 + num3;
document.write(num1 + ” + ” + num2 + ” + ” + num3 + ” = “);
} else if(op == s){
total = num1 – num2 – num3;
document.write(num1 + ” – ” + num2 + ” – ” + num3 + ” = “);
} else if(y == m){
total = num1 * num2
document.write(num1 + ” x ” + num2 + ” x ” + num3 + ” = “);
} else if(y == d){
total = num1/num2;
document.write(num1 + ” / ” + num2 + ” = “);
}
document.write(“</div>”);
}
function displayProblem(){
clearAll();
var op;
var max;
var ph2;
ph2 = Math.floor(Math.random()*4);
if(ph2 == 0){
op = a;
max = 100;
} else if(ph2 == 1){
op = s;
max = 100;
} else if(ph2 == 2){
op = m;
max = 10;
} else if(ph2 == 3){
op = d;
max = 10;
}
generate(max,op);
}
</script>
<style>
div.problemBubble{background-image:url(‘images/pinkbubble.jpg’); width:500px; height:200px; position:absolute; left:100px; top:400px;}
a.checkAnswer{width:50px;height:20px;background-color: hotpink;}
</style>
</head>
<body bgcolor=”white” text=”hotpink” onLoad=”displayProblem();return true;”>
<h1>Study Page</h1>
<hr width=”100%” color=”hotpink”>
</body>
</html>