I want to creat a post like this blog:
When you chose all the answers and click show answer a msg box will appear and tells how many answers are correct
I view the blog source and copied all the code to my post but it didn't work when i click the show answer button in my post.
Can any one help me with the code?
Thanks in advance
[html]1. Upon hatching, ________. <input id="text1" style="visibili ty: hidden; width: 1px;" value="A"><br /><input id="choice1A" value="A" name="choice1" type="radio"><l abel id="C1A">(A) young ducks know how to swim</label><br /><input id="choice1B" value="B" name="choice1" type="radio"><l abel id="C1B">(B) swimming is known by young ducks</label><br /><input id="choice1C" value="C" name="choice1" type="radio"><l abel id="C1C">(C) the knowledge of swimming is in young ducks</label><br /><input id="choice1D" value="D" name="choice1" type="radio"><l abel id="C1D">(D) how to swim is known in young ducks</label><br />2. Some of the rainwater from clouds evaporates before ________. <input id="text2" style="visibili ty: hidden; width: 1px;" value="A"><br /><input id="choice2A" value="A" name="choice2" type="radio"><l abel id="C2A">(A) reaching the ground</label><br /><input id="choice2B" value="B" name="choice2" type="radio"><l abel id="C2B">(B) to reach the ground</label><br /><input id="choice2C" value="C" name="choice2" type="radio"><l abel id="C2C">(C) reach the ground</label><br /><input id="choice2D" value="D" name="choice2" type="radio"><l abel id="C2D">(D) the ground reaches</label><br /><input language="javas cript" id="button1" onclick="button 1_onclick();" value="Show answers" name="button1" type="button">
[/HTML]
[CODE=javascript]<script id="clientEvent HandlersJS" language="javas cript">
function button1_onclick () {
var correct,Total;
Total=0;
correct= 0;
oElement = document.getEle mentById("choic e1A");
if (oElement) {
Total=Total+1
document.getEle mentById("choic e1A").disabled= true;
if ((document.getE lementById("cho ice1A").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1A").checke d)) correct=correct +1;
document.getEle mentById("choic e1B").disabled= true;
if ((document.getE lementById("cho ice1B").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1B").checke d)) correct=correct +1;
document.getEle mentById("choic e1C").disabled= true;
if ((document.getE lementById("cho ice1C").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1C").checke d)) correct=correct +1;
document.getEle mentById("choic e1D").disabled= true;
if ((document.getE lementById("cho ice1D").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1D").checke d)) correct=correct +1;
if ((document.getE lementById("cho ice1A").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1A") .style.color='r ed';
if ((document.getE lementById("cho ice1B").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1B") .style.color='r ed';
if ((document.getE lementById("cho ice1C").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1C") .style.color='r ed';
if ((document.getE lementById("cho ice1D").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1D") .style.color='r ed';
}
oElement = document.getEle mentById("choic e2A");
if (oElement) {
Total=Total+1
document.getEle mentById("choic e2A").disabled= true;
if ((document.getE lementById("cho ice2A").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2A").checke d)) correct=correct +1;
document.getEle mentById("choic e2B").disabled= true;
if ((document.getE lementById("cho ice2B").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2B").checke d)) correct=correct +1;
document.getEle mentById("choic e2C").disabled= true;
if ((document.getE lementById("cho ice2C").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2C").checke d)) correct=correct +1;
document.getEle mentById("choic e2D").disabled= true;
if ((document.getE lementById("cho ice2D").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2D").checke d)) correct=correct +1;
if ((document.getE lementById("cho ice2A").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2A") .style.color='r ed';
if ((document.getE lementById("cho ice2B").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2B") .style.color='r ed';
if ((document.getE lementById("cho ice2C").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2C") .style.color='r ed';
if ((document.getE lementById("cho ice2D").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2D") .style.color='r ed';
}
document.getEle mentById("butto n1").disabled=t rue;
alert(" Tra loi dung " + correct + " cau trong tong so " + Total + " cau.");
}
</script>[/CODE]
When you chose all the answers and click show answer a msg box will appear and tells how many answers are correct
I view the blog source and copied all the code to my post but it didn't work when i click the show answer button in my post.
Can any one help me with the code?
Thanks in advance
[html]1. Upon hatching, ________. <input id="text1" style="visibili ty: hidden; width: 1px;" value="A"><br /><input id="choice1A" value="A" name="choice1" type="radio"><l abel id="C1A">(A) young ducks know how to swim</label><br /><input id="choice1B" value="B" name="choice1" type="radio"><l abel id="C1B">(B) swimming is known by young ducks</label><br /><input id="choice1C" value="C" name="choice1" type="radio"><l abel id="C1C">(C) the knowledge of swimming is in young ducks</label><br /><input id="choice1D" value="D" name="choice1" type="radio"><l abel id="C1D">(D) how to swim is known in young ducks</label><br />2. Some of the rainwater from clouds evaporates before ________. <input id="text2" style="visibili ty: hidden; width: 1px;" value="A"><br /><input id="choice2A" value="A" name="choice2" type="radio"><l abel id="C2A">(A) reaching the ground</label><br /><input id="choice2B" value="B" name="choice2" type="radio"><l abel id="C2B">(B) to reach the ground</label><br /><input id="choice2C" value="C" name="choice2" type="radio"><l abel id="C2C">(C) reach the ground</label><br /><input id="choice2D" value="D" name="choice2" type="radio"><l abel id="C2D">(D) the ground reaches</label><br /><input language="javas cript" id="button1" onclick="button 1_onclick();" value="Show answers" name="button1" type="button">
[/HTML]
[CODE=javascript]<script id="clientEvent HandlersJS" language="javas cript">
function button1_onclick () {
var correct,Total;
Total=0;
correct= 0;
oElement = document.getEle mentById("choic e1A");
if (oElement) {
Total=Total+1
document.getEle mentById("choic e1A").disabled= true;
if ((document.getE lementById("cho ice1A").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1A").checke d)) correct=correct +1;
document.getEle mentById("choic e1B").disabled= true;
if ((document.getE lementById("cho ice1B").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1B").checke d)) correct=correct +1;
document.getEle mentById("choic e1C").disabled= true;
if ((document.getE lementById("cho ice1C").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1C").checke d)) correct=correct +1;
document.getEle mentById("choic e1D").disabled= true;
if ((document.getE lementById("cho ice1D").value== document.getEle mentById("text1 ").value) &&(document.get ElementById("ch oice1D").checke d)) correct=correct +1;
if ((document.getE lementById("cho ice1A").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1A") .style.color='r ed';
if ((document.getE lementById("cho ice1B").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1B") .style.color='r ed';
if ((document.getE lementById("cho ice1C").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1C") .style.color='r ed';
if ((document.getE lementById("cho ice1D").value== document.getEle mentById("text1 ").value)) document.getEle mentById("C1D") .style.color='r ed';
}
oElement = document.getEle mentById("choic e2A");
if (oElement) {
Total=Total+1
document.getEle mentById("choic e2A").disabled= true;
if ((document.getE lementById("cho ice2A").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2A").checke d)) correct=correct +1;
document.getEle mentById("choic e2B").disabled= true;
if ((document.getE lementById("cho ice2B").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2B").checke d)) correct=correct +1;
document.getEle mentById("choic e2C").disabled= true;
if ((document.getE lementById("cho ice2C").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2C").checke d)) correct=correct +1;
document.getEle mentById("choic e2D").disabled= true;
if ((document.getE lementById("cho ice2D").value== document.getEle mentById("text2 ").value) &&(document.get ElementById("ch oice2D").checke d)) correct=correct +1;
if ((document.getE lementById("cho ice2A").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2A") .style.color='r ed';
if ((document.getE lementById("cho ice2B").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2B") .style.color='r ed';
if ((document.getE lementById("cho ice2C").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2C") .style.color='r ed';
if ((document.getE lementById("cho ice2D").value== document.getEle mentById("text2 ").value)) document.getEle mentById("C2D") .style.color='r ed';
}
document.getEle mentById("butto n1").disabled=t rue;
alert(" Tra loi dung " + correct + " cau trong tong so " + Total + " cau.");
}
</script>[/CODE]
Comment