Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Java script button help.  (Read 2974 times)

0 Members and 1 Guest are viewing this topic.

Tusker

    Topic Starter


    Greenhorn

    Java script button help.
    « on: June 05, 2008, 01:30:20 AM »
    I ve found  this is  in Javascript question form.
    Ive copied  the form and intend to change the values with my own subjects.Question is how do i get
    the button at the bottom to tally up the scores?
    How do i get it to work? THANKS
    The script is as below;
             <form>
                               <fieldset>
                                  <legend>英会話のレベルチェック 準中級</legend>
                                  <!--====[Column]====-->

                                  <div class="column" id="pre01">
                                     <h3>1) "How many times have you been to China?" "_____."</h3>
                                     <ul>
                                        <li><input type="radio" name="answer1" value="1" id="a01-1" /><label for="a01-1">One times.</label></li>
                                        <li><input type="radio" name="answer1" value="2" id="a01-2" /><label for="a01-2">Twice.</label></li>
                                        <li><input type="radio" name="answer1" value="3" id="a01-3" /><label for="a01-3">Twice times.</label></li>
                                        <li><input type="radio" name="answer1" value="4" id="a01-4" /><label for="a01-4">Only one.</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre02">
                                     <h3>2) _____ you ever been to Paris?</h3>
                                     <ul>
                                        <li><input type="radio" name="answer2" value="1" id="a02-1" /><label for="a02-1">Did</label></li>

                                        <li><input type="radio" name="answer2" value="2" id="a02-2" /><label for="a02-2">Have</label></li>
                                        <li><input type="radio" name="answer2" value="3" id="a02-3" /><label for="a02-3">Do</label></li>
                                        <li><input type="radio" name="answer2" value="4" id="a02-4" /><label for="a02-4">Has</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre03">
                                     <h3>3) I _____ my sister since last week.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer3" value="1" id="a03-1" /><label for="a03-1">aren't seeing</label></li>
                                        <li><input type="radio" name="answer3" value="2" id="a03-2" /><label for="a03-2">don't see</label></li>
                                        <li><input type="radio" name="answer3" value="3" id="a03-3" /><label for="a03-3">didn't see</label></li>
                                        <li><input type="radio" name="answer3" value="4" id="a03-4" /><label for="a03-4">haven't seen</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre04">
                                     <h3>4) "What about pizza?" "I'd rather ______ a sandwich."</h3>
                                     <ul>
                                        <li><input type="radio" name="answer4" value="1" id="a04-1" /><label for="a04-1">to have</label></li>

                                        <li><input type="radio" name="answer4" value="2" id="a04-2" /><label for="a04-2">have to</label></li>
                                        <li><input type="radio" name="answer4" value="3" id="a04-3" /><label for="a04-3">having</label></li>
                                        <li><input type="radio" name="answer4" value="4" id="a04-4" /><label for="a04-4">have</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre05">
                                     <h3>5) "What are your plans tomorrow?"</h3>
                                     <ul>
                                        <li><input type="radio" name="answer5" value="1" id="a05-1" /><label for="a05-1">" I'm going to the office."</label></li>
                                        <li><input type="radio" name="answer5" value="2" id="a05-2" /><label for="a05-2">" I went to the office."</label></li>
                                        <li><input type="radio" name="answer5" value="3" id="a05-3" /><label for="a05-3">" I go to the office."</label></li>
                                        <li><input type="radio" name="answer5" value="4" id="a05-4" /><label for="a05-4">" I shall going to the office."</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre06">
                                     <h3>6) Choose the correct sentence.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer6" value="1" id="a06-1" /><label for="a06-1">If I were you I will study hard.</label></li>

                                        <li><input type="radio" name="answer6" value="2" id="a06-2" /><label for="a06-2">If I were you I'd study hard.</label></li>
                                        <li><input type="radio" name="answer6" value="3" id="a06-3" /><label for="a06-3">If I am you I'll study hard.</label></li>
                                        <li><input type="radio" name="answer6" value="4" id="a06-4" /><label for="a06-4">I'd study hard if I'll you.</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre07">
                                     <h3>7) Do you _____ to go and see him in the hospital?</h3>
                                     <ul>
                                        <li><input type="radio" name="answer7" value="1" id="a07-1" /><label for="a07-1">must</label></li>
                                        <li><input type="radio" name="answer7" value="2" id="a07-2" /><label for="a07-2">should</label></li>
                                        <li><input type="radio" name="answer7" value="3" id="a07-3" /><label for="a07-3">have</label></li>
                                        <li><input type="radio" name="answer7" value="4" id="a07-4" /><label for="a07-4">will</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre08">
                                     <h3>8) Madonna is the singer _____ sang "Holiday."</h3>
                                     <ul>
                                        <li><input type="radio" name="answer8" value="1" id="a08-1" /><label for="a08-1">who's</label></li>

                                        <li><input type="radio" name="answer8" value="2" id="a08-2" /><label for="a08-2">where</label></li>
                                        <li><input type="radio" name="answer8" value="3" id="a08-3" /><label for="a08-3">whose</label></li>
                                        <li><input type="radio" name="answer8" value="4" id="a08-4" /><label for="a08-4">who</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre09">
                                     <h3>9) I'd prefer one _____ has a handle.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer9" value="1" id="a09-1" /><label for="a09-1">who</label></li>
                                        <li><input type="radio" name="answer9" value="2" id="a09-2" /><label for="a09-2">which</label></li>
                                        <li><input type="radio" name="answer9" value="3" id="a09-3" /><label for="a09-3">witch</label></li>
                                        <li><input type="radio" name="answer9" value="4" id="a09-4" /><label for="a09-4">where</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre10">
                                     <h3>10) Choose the correct sentence.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer10" value="1" id="a10-1" /><label for="a10-1">I've seen just Chris.</label></li>

                                        <li><input type="radio" name="answer10" value="2" id="a10-2" /><label for="a10-2">I've Chris just seen.</label></li>
                                        <li><input type="radio" name="answer10" value="3" id="a10-3" /><label for="a10-3">I just have seen Chris.</label></li>
                                        <li><input type="radio" name="answer10" value="4" id="a10-4" /><label for="a10-4">I've just seen Chris.</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre11">
                                     <h3>11) "What did he say?"</h3>
                                     <ul>
                                        <li><input type="radio" name="answer11" value="1" id="a11-1" /><label for="a11-1">" He me told that he really liked you."</label></li>
                                        <li><input type="radio" name="answer11" value="2" id="a11-2" /><label for="a11-2">" He told me that he really like you."</label></li>
                                        <li><input type="radio" name="answer11" value="3" id="a11-3" /><label for="a11-3">" He told me that he really liked you."</label></li>
                                        <li><input type="radio" name="answer11" value="4" id="a11-4" /><label for="a11-4">" He told me that he has really liked you."</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->
                                  <div class="column" id="pre12">
                                     <h3>12) Don't wait, I _____ late.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer12" value="1" id="a12-1" /><label for="a12-1">can</label></li>

                                        <li><input type="radio" name="answer12" value="2" id="a12-2" /><label for="a12-2">might to be</label></li>
                                        <li><input type="radio" name="answer12" value="3" id="a12-3" /><label for="a12-3">can't be</label></li>
                                        <li><input type="radio" name="answer12" value="4" id="a12-4" /><label for="a12-4">could be</label></li>
                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <!--====[Column]====-->

                                  <div class="column" id="pre13">
                                     <h3>13) Well it's nine o'clock, he _____ running late.</h3>
                                     <ul>
                                        <li><input type="radio" name="answer13" value="1" id="a13-1" /><label for="a13-1">could</label></li>
                                        <li><input type="radio" name="answer13" value="2" id="a13-2" /><label for="a13-2">must</label></li>
                                        <li><input type="radio" name="answer13" value="3" id="a13-3" /><label for="a13-3">must be</label></li>
                                        <li><input type="radio" name="answer13" value="4" id="a13-4" /><label for="a13-4">must to be</label></li>

                                     </ul>
                                  </div>
                                  <!--====[//Column]====-->
                                  <input type="button" value="採点する" onclick="checkAnswers()" name="button" />
                               </fieldset>
                            </form>


    Astoria



      Intermediate

      Re: Java script button help.
      « Reply #1 on: June 05, 2008, 12:25:27 PM »
      So where's the JS at? This is all HTML you're showing.

      You need either a JS file, or the script within the HTML <head> and </head> with the function:
      checkAnswers(). This is the function that's called upon when the button is clicked.

      From what you show, there is no JS.