Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. function fire() {
  2.  
  3. var rad1=document.getElementsByName('choose1');
  4. var rad2=document.getElementsByName('choose2');
  5. var rad3=document.getElementsByName('choose3');
  6. for (var a=0;a<rad1.length; a++) {
  7. if (rad1[a].checked) {
  8. //alert(a+1);
  9.  
  10.  
  11. for (var b=0;b<rad2.length; b++) {
  12. if (rad2[b].checked) {
  13. //alert(b+1);
  14.  
  15. for (var c=0;c<rad3.length; c++) {
  16. if (rad3[c].checked) {
  17. //alert(c+1);
  18. var j = a+1+b+1+c+1;
  19. document.getElementById('txt').innerHTML = j;
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27.  
  28. /*
  29. <!DOCTYPE html>
  30. <html>
  31. <head>
  32. <title></title>
  33. <meta charset="utf-8">
  34. <script src="jquery-3.3.1.min.js"></script>
  35. </head>
  36. <body>
  37. <div class="box">
  38. <div class="b1" style="width:100%; float:left; position:relative; background:lightblue; padding:0 0 10px 15px;">
  39. <h2>одні питання</h2>
  40. <input type="radio" name="choose1" id="one" class="one"><label for="one">відповідь з одним балом</label><br>
  41. <input type="radio" name="choose1" class="two"><label for="two">відповідь з двома баломи</label><br>
  42. <input type="radio" name="choose1" class="three"><label for="three">відповідь з трьома баломи</label>
  43. </div>
  44. <div class="b2" style="width:100%; float:left; position:relative; background:lightgreen; padding:0 0 10px 15px;">
  45. <h2>інші питання</h2>
  46. <input type="radio" name="choose2" id="one" class="one"><label for="one">відповідь з одним балом</label><br>
  47. <input type="radio" name="choose2" class="two"><label for="two">відповідь з двома баломи</label><br>
  48. <input type="radio" name="choose2" class="three"><label for="three">відповідь з трьома баломи</label>
  49. </div>
  50. <div class="b3" style="width:100%; float:left; position:relative; background:lightgray; padding:0 0 10px 15px;">
  51. <h2>ще інші питання</h2>
  52. <input type="radio" name="choose3" id="one" class="one"><label for="one">відповідь з одним балом</label><br>
  53. <input type="radio" name="choose3" class="two"><label for="two">відповідь з двома баломи</label><br>
  54. <input type="radio" name="choose3" class="three"><label for="three">відповідь з трьома баломи</label>
  55. </div>
  56. <button onclick="fire()" class="fire">підрахувати</button>
  57. <div id="txt" style="width:20%; height:25px; background:pink;">
  58. <h4>блок з сумованими балами</h4>
  59. </div>
  60. </div>
  61. </body>
  62. <script src="script2.js"></script>
  63. </html>
  64. */
  65. //Прогр. підрах. ввімк. радіобуттонів
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement