Show how many answers are correct on clicking a button

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • acoder
    replied
    If you check the error console, you will see errors, e.g.
    missing ; before statement
    http://studyenglishchi nese.blogspot.c om/
    Line 153
    missing { before function body
    http://studyenglishchi nese.blogspot.c om/
    Line 197
    Correct them (by adding ; and {).

    Leave a comment:


  • onetruelove
    replied
    I replace all the <br/> with document.write( "<br />") but it can't help. When i clicked on show answers it doesn't not work. I don't know why this blog can do
    http://onlinetoefltest .blogspot.com/2007/08/toefl-lesson-1.html
    I just copied the code from this blog and post in mine. Thank you very much Vee10. I really appreciated your help.

    Leave a comment:


  • vee10
    replied
    Hi

    some of the button1_onclick () has no' { ' try to place them
    by finding the button1_onclick ().

    and in the script functions u should not use the <br /> directly u should use that by using document.write( ) like document.write( "<br />");

    try to remove the <br /> in all the scripts function then ur function will work.
    since i have checked that i am making this comment .

    it works fine if u remove <br/> and place it in document.write( "<br />");




    Originally posted by rohitchawla
    i havent seen much of your code but when i went to your test page, you seem to be missing an opening bracket after your function button1_onclick () in line 194
    [HTML]<script id="clientEvent HandlersJS" language="javas cript">function button1_onclick () var correct,Total;. ......[/HTML]

    and in line 234 u have put a <br /> in js code after the function button1_onclick ()
    [HTML]script id="clientEvent HandlersJS" language="javas cript">function button1_onclick () <br />{var correct,Total;T otal=0;........[/HTML]

    and in line 274
    [HTML]<script id="clientEvent HandlersJS" language="javas cript"><br />function button1_onclick () {<br />var correct,Total;< br />Total=0....... ..[/HTML]

    and in line 150
    [HTML]<script id="clientEvent HandlersJS" type="text/javascript"><br /><br />function button1_onclick () {<br /><br />var correct,Total;< br /><br />Total=0;<br /><br />correct= 0..........[/HTML]

    and all of these scripts have same id

    Leave a comment:


  • vee10
    replied
    Hi

    some of the button1_onclick () has no' { ' try to place them
    by finding the button1_onclick ().

    and in the script functions u should not use the <br /> directly u should use that by using document.write( ) like document.write( "<br />");

    try to remove the <br /> in all the scripts function then ur function will work.
    since i have checked that i am making this comment .

    it works fine if u remove <br/> and place it in document.write( "<br />");

    Originally posted by onetruelove
    I want to creat a post like this blog:
    Trình độ C - Bài 1 1. Food prices have been ________ steadily for at least twenty years. (A) rising (B) raising (C) lifting (D) growing 2....


    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
    Last edited by acoder; Feb 20 '08, 07:37 AM.

    Leave a comment:


  • rohitchawla
    replied
    i havent seen much of your code but when i went to your test page, you seem to be missing an opening bracket after your function button1_onclick () in line 194
    [HTML]<script id="clientEvent HandlersJS" language="javas cript">function button1_onclick () var correct,Total;. ......[/HTML]

    and in line 234 u have put a <br /> in js code after the function button1_onclick ()
    [HTML]script id="clientEvent HandlersJS" language="javas cript">function button1_onclick () <br />{var correct,Total;T otal=0;........[/HTML]

    and in line 274
    [HTML]<script id="clientEvent HandlersJS" language="javas cript"><br />function button1_onclick () {<br />var correct,Total;< br />Total=0....... ..[/HTML]

    and in line 150
    [HTML]<script id="clientEvent HandlersJS" type="text/javascript"><br /><br />function button1_onclick () {<br /><br />var correct,Total;< br /><br />Total=0;<br /><br />correct= 0..........[/HTML]

    and all of these scripts have same id

    Leave a comment:


  • onetruelove
    replied
    This is a free website for people who want to study English, Chinese. Come to our website to have a great time learning, relaxing with music, movies and ebooks. 免费学习英语,中文,音乐,电子书。


    I don't know why when i clicked the show answers button nothing happened although the code is right because i've tested the code of Evrsoft. How can it work in blogger, i don't know if blogger needs a special editor to edit it.

    Here is the code:

    [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]
    [HTML]1. Upon hatching, ________. <input id="text1" style="visibili ty: hidden; width: 1px;" value="A">
    <input id="choice1A" value="A" name="choice1" type="radio"><l abel id="C1A">(A) young ducks know how to swim</label>
    <input id="choice1B" value="B" name="choice1" type="radio"><l abel id="C1B">(B) swimming is known by young ducks</label>
    <input id="choice1C" value="C" name="choice1" type="radio"><l abel id="C1C">(C) the knowledge of swimming is in young ducks</label>
    <input id="choice1D" value="D" name="choice1" type="radio"><l abel id="C1D">(D) how to swim is known in young ducks</label>
    2. Some of the rainwater from clouds evaporates before ________. <input id="text2" style="visibili ty: hidden; width: 1px;" value="A">
    <input id="choice2A" value="A" name="choice2" type="radio"><l abel id="C2A">(A) reaching the ground</label>
    <input id="choice2B" value="B" name="choice2" type="radio"><l abel id="C2B">(B) to reach the ground</label>
    <input id="choice2C" value="C" name="choice2" type="radio"><l abel id="C2C">(C) reach the ground</label>
    <input id="choice2D" value="D" name="choice2" type="radio"><l abel id="C2D">(D) the ground reaches</label>
    <input language="javas cript" id="button1" onclick="button 1_onclick();" value="Show answer[/HTML]
    Last edited by acoder; Feb 20 '08, 07:36 AM. Reason: Added code tags

    Leave a comment:


  • acoder
    replied
    Can you post a link to your version.

    Leave a comment:


  • onetruelove
    replied
    Originally posted by acoder
    So what happens in your version? Do you get any errors?
    The code is all correct but when i post a new blog in blogger, it doesn't work.

    Leave a comment:


  • acoder
    replied
    Originally posted by onetruelove
    I want to creat a post like this blog:
    Trình độ C - Bài 1 1. Food prices have been ________ steadily for at least twenty years. (A) rising (B) raising (C) lifting (D) growing 2....


    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?
    So what happens in your version? Do you get any errors?

    Leave a comment:


  • acoder
    replied
    Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

    This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

    MODERATOR

    Leave a comment:


  • Show how many answers are correct on clicking a button

    I want to creat a post like this blog:
    Trình độ C - Bài 1 1. Food prices have been ________ steadily for at least twenty years. (A) rising (B) raising (C) lifting (D) growing 2....


    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]
    Last edited by acoder; Feb 16 '08, 01:14 PM. Reason: Added code tags
Working...