2013-02-20 71 views
-1

我想做一個簡單的測試,通過單選按鈕提問和回答標記,但我卡住了。如何在JavaScript中獲得積極答案的總和?

我有6個單獨的測試全部通過10個問題,你會看到代碼。我通過10個問題做了兩個測試,我的問題是讓他們成爲個人,這樣我就可以得到不同的答案。

我想要的是當某人標記爲「是」時,他/她在測試結束時得到肯定答案或「是」答案。

下面是代碼:

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<script type="text/javascript"> 
     function DisplayPrice(price){ 
      var val1 = 0; 
      for(i = 0; i < document.form1.price.length; i++){ 
       if(document.form1.price[i].checked == true){ 
        val1 = document.form1.price[i].value; 
       } 
      } 

      var val2 = 0; 
      for(i = 0; i < document.form2.price2.length; i++){ 
       if(document.form2.price2[i].checked == true){ 
        val2 = document.form2.price2[i].value; 
       } 
      } 

      var val3 = 0; 
      for(i = 0; i < document.form3.price3.length; i++){ 
       if(document.form3.price3[i].checked == true){ 
        val3 = document.form3.price3[i].value; 
       } 
      } 

      var val4 = 0; 
      for(i = 0; i < document.form4.price4.length; i++){ 
       if(document.form4.price4[i].checked == true){ 
        val4 = document.form4.price4[i].value; 
       } 
      } 

      var val5 = 0; 
      for(i = 0; i < document.form5.price5.length; i++){ 
       if(document.form5.price5[i].checked == true){ 
        val5 = document.form5.price5[i].value; 
       } 
      } 

      var val6 = 0; 
      for(i = 0; i < document.form6.price6.length; i++){ 
       if(document.form6.price6[i].checked == true){ 
        val6 = document.form6.price6[i].value; 
       } 
      } 

      var val7 = 0; 
      for(i = 0; i < document.form7.price7.length; i++){ 
       if(document.form7.price7[i].checked == true){ 
        val7 = document.form7.price7[i].value; 
       } 
      } 

      var val8 = 0; 
      for(i = 0; i < document.form8.price8.length; i++){ 
       if(document.form8.price8[i].checked == true){ 
        val8 = document.form8.price8[i].value; 
       } 
      } 

      var val9 = 0; 
      for(i = 0; i < document.form9.price9.length; i++){ 
       if(document.form9.price9[i].checked == true){ 
        val9 = document.form9.price9[i].value; 
       } 
      } 

      var val10 = 0; 
      for(i = 0; i < document.form10.price10.length; i++){ 
       if(document.form10.price10[i].checked == true){ 
        val10 = document.form10.price10[i].value; 
       } 
      } 


      var sum=parseInt(val1) + parseInt(val2) + parseInt(val3) + parseInt(val4) + parseInt(val5) + parseInt(val6) + parseInt(val7) + parseInt(val8) + parseInt(val9) + parseInt(val10); 
      document.getElementById('totalSum').value=sum; 
     } 
    </script> 
<style type="text/css"> 
body,td,th { 
    color: #03C; 
} 
body { 
    background-color: #999; 
    text-align: left; 
} 
</style> 
</head> 
<body> 
<h2><strong>TEST 1</strong></h2> 
<form name="form1" id="form1" runat="server"> 
    <h3><br> 
    QUESTION1. 
     <input id="rdo_1" type="radio" value="1" name="price" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
    <form name="form2" id="form2" runat="server"> 
     <h3><br> 
     QUESTION2. 
     <input id="rdo_1" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
     NO<br> 
     </h3> 
    </form> 
<form name="form3" id="form3" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_1" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form4" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_1" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form5" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_1" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form6" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_1" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form7" runat="server"> 
    <h3>QUESTION7. 
     <input id="rdo_1" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form8" id="form8" runat="server"> 
    <h3><br> 
    QUESTION8. 
     <input id="rdo_1" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form9" id="form9" runat="server"> 
    <h3><br> 
    QUESTION9. 
     <input id="rdo_1" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form10" id="form10" runat="server"> 
    <h3>QUESTION10. 
    <input id="rdo_1" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<p>&nbsp;</p> 
<h2><strong>TEST 2</strong></h2> 
<form name="form1" id="form11" runat="server"> 
    <h3><br> 
    QUESTION1. 
    <input id="rdo_3" type="radio" value="1" name="price" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form2" id="form12" runat="server"> 
    <h3><br> 
    QUESTION2. 
    <input id="rdo_3" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form3" id="form13" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_3" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form14" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_3" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form15" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_3" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form16" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_3" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form17" runat="server"> 
    <h3>QUESTION7. 
    <input id="rdo_3" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form8" id="form18" runat="server"> 
    <h3><br> 
    QUESTION8. 
    <input id="rdo_3" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form9" id="form19" runat="server"> 
    <h3><br> 
    QUESTION9. 
    <input id="rdo_3" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
    NO <br> 
    </h3> 
</form> 
<form name="form10" id="form20" runat="server"> 
    <h3><br> 
    QUESTION10. 
    <input id="rdo_3" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    DA 
    <input id="rdo_4" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NE<br> 
    </h3> 
</form> 
<h2>Score &quot;TEST1&quot; 
    <input type="text" name="totalSum" id="totalSum" value="" size="3" readonly="readonly"> 
</h2> 
<h2>Score &quot;TEST2&quot; 
    <input type="text" name="totalSum2" id="totalSum2" value="" size="3" readonly="readonly"> 
</h2> 
</body> 

回答

0

我已經編輯好javascript得到它在谷歌瀏覽器去。我概括了你引用表單元素的方式。

function DisplayPrice(price){ 

     var mysum=0, mysum2 =0, mysm3=0, mysum4=0, num, ele, frm,f,e; 

     for(f in document.forms) 
     { 
      frm = document.forms[f]; 
      for(e in frm.elements) 
      { 
       ele = frm.elements[e]; 
       if (ele.checked && ele.value) 
       { 
        // based on ID we decide if TEST1 or TEST2 is counting 
        num = parseInt(frm.id.substr(4),10); 
        if (num < 11) { 
          mysum = mysum + parseInt(ele.value,10); 
        } else if (num < 21) { 
          mysum2 = mysum2 + parseInt(ele.value,10); 
        } else if (num < 31) { 
          mysum3 = mysum3 + parseInt(ele.value,10); 
        } else { 
          mysum4 = mysum4 + parseInt(ele.value,10); 
        } 
       } 
      } 
     } 

     document.getElementById('totalSum').value=mysum; 
     document.getElementById('totalSum2').value=mysum2; 
     document.getElementById('totalSum3').value=mysum3; 
     document.getElementById('totalSum4').value=mysum4; 

    } 

對於每個人都有效的工作JSFiddle來測試的東西。

+0

劉若英,非常感謝你,一切都正常工作;) – user2092760 2013-02-23 11:40:38

+0

卻得到了一個新的問題:/我需要6次個人測試中,我讓4他們和..現在反混合nubers:/我將編輯我的答案,並把新的代碼在其中..如果你可以看看 – user2092760 2013-02-23 12:07:32

+0

你最好接受這個答案,並提出新的問題。假設你保持html格式類似,我已經更新了這個版本以使用4個測試。 – rene 2013-02-23 13:21:39

0

編輯: 這裏是新的代碼...:/

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<script type="text/javascript"> 
     function DisplayPrice(price){ 

      var mysum=0, mysum2 =0, mysum3 =0, mysum4 =0, num, ele, frm,f,e; 

      for(f in document.forms) 
      { 
       frm = document.forms[f]; 
       for(e in frm.elements) 
       { 
        ele = frm.elements[e]; 
        if (ele.checked && ele.value) 
        { 
         num = parseInt(frm.id.substr(4),10); 
         if (num < 11) { 
           mysum = mysum + parseInt(ele.value,10); 
         } else { 
           mysum2 = mysum2 + parseInt(ele.value,10); 
         if (num < 21) { 
           mysum3 = mysum3 + parseInt(ele.value,10); 
         } else { 
           mysum4 = mysum4 + parseInt(ele.value,10); 
         } 


         } 
        } 
       } 
      } 

      document.getElementById('totalSum').value=mysum; 
      document.getElementById('totalSum2').value=mysum2; 
      document.getElementById('totalSum3').value=mysum3; 
      document.getElementById('totalSum4').value=mysum4; 
     } 

window.DisplayPrice=DisplayPrice; 
    </script> 
<style type="text/css"> 
body,td,th { 
    color: #03C; 
} 
body { 
    background-color: #999; 
    text-align: left; 
} 
</style> 
</head> 
<body> 
<h2><strong>TEST 1</strong></h2> 
<form name="form1" id="form1" runat="server"> 
    <h3><br> 
    QUESTION1. 
     <input id="rdo_1" type="radio" value="1" name="price" onClick="DisplayPrice(this.value)"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
    <form name="form2" id="form2" runat="server"> 
     <h3><br> 
     QUESTION2. 
     <input id="rdo_1" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
     NO<br> 
     </h3> 
    </form> 
<form name="form3" id="form3" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_1" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form4" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_1" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form5" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_1" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form6" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_1" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form7" runat="server"> 
    <h3>QUESTION7. 
     <input id="rdo_1" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form8" id="form8" runat="server"> 
    <h3><br> 
    QUESTION8. 
     <input id="rdo_1" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form9" id="form9" runat="server"> 
    <h3><br> 
    QUESTION9. 
     <input id="rdo_1" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
     YES 
     <input id="rdo_2" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
     NO<br> 
    </h3> 
</form> 
<form name="form10" id="form10" runat="server"> 
    <h3>QUESTION10. 
    <input id="rdo_1" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_2" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<p>&nbsp;</p> 
<h2><strong>TEST 2</strong></h2> 
<form name="form1" id="form11" runat="server"> 
    <h3><br> 
    QUESTION1. 
    <input id="rdo_3" type="radio" value="1" name="price" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form2" id="form12" runat="server"> 
    <h3><br> 
    QUESTION2. 
    <input id="rdo_3" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form3" id="form13" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_3" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form14" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_3" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form15" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_3" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form16" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_3" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form17" runat="server"> 
    <h3>QUESTION7. 
    <input id="rdo_3" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form8" id="form18" runat="server"> 
    <h3><br> 
    QUESTION8. 
    <input id="rdo_3" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form9" id="form19" runat="server"> 
    <h3><br> 
    QUESTION9. 
    <input id="rdo_3" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
    NO <br> 
    </h3> 
</form> 
<form name="form10" id="form20" runat="server"> 
    <h3><br> 
    QUESTION10. 
    <input id="rdo_3" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    DA 
    <input id="rdo_4" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NE<br> 
    </h3> 
</form> 
<h2><strong>TEST 3</strong></h2> 
<form name="form1" id="form21" runat="server"> 
    <h3><br> 
    QUESTION1. 
    <input id="rdo_3" type="radio" value="1" name="price" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form2" id="form22" runat="server"> 
    <h3><br> 
    QUESTION2. 
    <input id="rdo_3" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form3" id="form23" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_3" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form24" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_3" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form25" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_3" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form26" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_3" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form27" runat="server"> 
    <h3>QUESTION7. 
    <input id="rdo_3" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form8" id="form28" runat="server"> 
    <h3><br> 
    QUESTION8. 
    <input id="rdo_3" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form9" id="form29" runat="server"> 
    <h3><br> 
    QUESTION9. 
    <input id="rdo_3" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
    NO <br> 
    </h3> 
</form> 
<form name="form10" id="form30" runat="server"> 
    <h3><br> 
    QUESTION10. 
    <input id="rdo_3" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    DA 
    <input id="rdo_4" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NE<br> 
    </h3> 
</form> 
<h2><strong>TEST 4</strong></h2> 
<form name="form1" id="form31" runat="server"> 
    <h3><br> 
    QUESTION1. 
    <input id="rdo_3" type="radio" value="1" name="price" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form2" id="form32" runat="server"> 
    <h3><br> 
    QUESTION2. 
    <input id="rdo_3" type="radio" value="1" name="price2" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price2" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form3" id="form33" runat="server"> 
    <h3><br> 
    QUESTION3. 
    <input id="rdo_3" type="radio" value="1" name="price3" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price3" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form4" id="form34" runat="server"> 
    <h3><br> 
    QUESTION4. 
    <input id="rdo_3" type="radio" value="1" name="price4" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price4" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form5" id="form35" runat="server"> 
    <h3><br> 
    QUESTION5. 
    <input id="rdo_3" type="radio" value="1" name="price5" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price5" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form6" id="form36" runat="server"> 
    <h3><br> 
    QUESTION6. 
    <input id="rdo_3" type="radio" value="1" name="price6" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price6" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form7" id="form37" runat="server"> 
    <h3>QUESTION7. 
    <input id="rdo_3" type="radio" value="1" name="price7" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price7" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form8" id="form38" runat="server"> 
    <h3><br> 
    QUESTION8. 
    <input id="rdo_3" type="radio" value="1" name="price8" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price8" onClick="DisplayPrice(this.value);"> 
    NO<br> 
    </h3> 
</form> 
<form name="form9" id="form39" runat="server"> 
    <h3><br> 
    QUESTION9. 
    <input id="rdo_3" type="radio" value="1" name="price9" onClick="DisplayPrice(this.value);"> 
    YES 
    <input id="rdo_4" type="radio" value="0" name="price9" onClick="DisplayPrice(this.value);"> 
    NO <br> 
    </h3> 
</form> 
<form name="form10" id="form40" runat="server"> 
    <h3><br> 
    QUESTION10. 
    <input id="rdo_3" type="radio" value="1" name="price10" onClick="DisplayPrice(this.value);"> 
    DA 
    <input id="rdo_4" type="radio" value="0" name="price10" onClick="DisplayPrice(this.value);"> 
    NE<br> 
    </h3> 
</form> 
<h2>Score &quot;TEST1&quot; 
    <input type="text" name="totalSum" id="totalSum" value="" size="3" readonly="readonly"> 
</h2> 
<h2>Score &quot;TEST2&quot; 
    <input type="text" name="totalSum2" id="totalSum2" value="" size="3" readonly="readonly"> 
</h2> 
<h2>Score &quot;TEST3&quot; 
    <input type="text" name="totalSum3" id="totalSum3" value="" size="3" readonly="readonly"> 
</h2> 
<h2>Score &quot;TEST3&quot; 
    <input type="text" name="totalSum4" id="totalSum4" value="" size="3" readonly="readonly"> 
</h2> 
</body> 
+0

看看我更新的答案。 – rene 2013-02-22 22:49:53

+0

我編輯了這個答案,並把修改後的代碼..但有些錯誤:/ – user2092760 2013-02-23 12:09:19