Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 08.04.2014, 22:12
Новичок на форуме
Отправить личное сообщение для doom2154 Посмотреть профиль Найти все сообщения от doom2154
 
Регистрация: 08.04.2014
Сообщений: 2

Тест написанный на java script
Всем привет, возник вопрос помогите пжл- есть тэст но немогу понять как сделать так чтобы он различал правильные и не правильные ответы помогите пжл и правильный код, тоесть надо сделать так чтобы скрипт отбирал правильный ответ и отсеивал его потом писал какое кол-во ответов правильно и не правильно.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type = "text/css">
            div.questionBlock {
                display: none;
            }
        </style>
        <script type = "text/javascript">
            var answer;
        </script
<title> Сборка ПК - Контактная информация </title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="wrap">
  <div id="masthead">
    <h1>Все о сборке ПК</h1>
    <div id="menucontainer">
      <div id="menunav">
        <ul>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Главная.html"><span>Главная</span></a></li>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Обучение.html"><span>Обучение</span></a></li>
          <li><a href="F:\Web-Сайт\[url]www.sborka-pk.ru\Контактная[/url] информация.html" class="current"><span>Контактная информация  </span></a></li>
        </ul>
       </div>
    </div>
  </div>
  <br>
  <font size="+2"><p align="center">
	  Тест по теме: Знакомство с ПК и его составными</font></p>
	  <div class = "questionBlock">
	  <font size="+1">
			
			<br>
			
			Вопрос 1:<br>
            <input type = "radio" name=q1 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q1 onclick="qa.nowRight = 1">2)<br>
            <input type = "radio" name=q1 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q1 onclick="qa.nowRight = 0">4)<br> 
			</div>
			<br>
			Вопрос 2:<br>
            <input type = "radio" name=q2 onclick="qa.nowRight = 1">1)<br>
            <input type = "radio" name=q2 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q2 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q2 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 3:<br>
            <input type = "radio" name=q3 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q3 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q3 onclick="qa.nowRight = 1">3)<br>
            <input type = "radio" name=q3 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 4:<br>
            <input type = "radio" name=q4 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q4 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q4 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q4 onclick="qa.nowRight = 1">4)<br> 
			</div>		
			<br>
			Вопрос 5:<br>
            <input type = "radio" name=q5 onclick="qa.nowRight = 1">1)<br>
            <input type = "radio" name=q5 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q5 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q5 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 6:<br>
            <input type = "radio" name=q6 onclick="qa.nowRight = 1">1)<br>
            <input type = "radio" name=q6 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q6 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q6 onclick="qa.nowRight = 0">4)<br> 
			</div>			
			<br>
			Вопрос 7:<br>
            <input type = "radio" name=q7 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q7 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q7 onclick="qa.nowRight = 1">3)<br>
            <input type = "radio" name=q7 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 8:<br>
            <input type = "radio" name=q8 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q8 onclick="qa.nowRight = 1">2)<br>
            <input type = "radio" name=q8 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q8 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 9:<br>
            <input type = "radio" name=q9 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q9 onclick="qa.nowRight = 1">2)<br>
            <input type = "radio" name=q9 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q9 onclick="qa.nowRight = 0">4)<br> 
			</div>		
			<br>
			Вопрос 10:<br>
            <input type = "radio" name=q10 onclick="qa.nowRight = 0">1)<br>
            <input type = "radio" name=q10 onclick="qa.nowRight = 0">2)<br>
            <input type = "radio" name=q10 onclick="qa.nowRight = 0">3)<br>
            <input type = "radio" name=q10 onclick="qa.nowRight = 1">4)<br> 
			</div>
			</font>
			</h1>
			<br>
			<input type="button" value="Ответить"  onclick="qa.nextOrResult()"> 
			
		<script type = "text/javascript">
            var qa = new QuestAnalizer();
            function QuestAnalizer() {
                var now = 0, printed = false, rightCount = 2;
                var questionBlocks = document.querySelectorAll("div.questionBlock");
                var allQCount = questionBlocks.length;
                this.nowRight = 0;
                questionBlocks[now].style.display = "block";
                this.nextOrResult = function () {
                    if (now >= allQCount-1) {
                        now++;
                        if (!printed) {
                            questionBlocks[now - 1].style.display = "none"
                            var p = document.createElement("p");
                            p.innerHTML = "Верных ответов " + rightCount + ". Вы набрали " + (rightCount / allQCount * 100).toFixed(0) + "%";
                            document.body.appendChild(p);
                            printed = true;
                        } else {
                            alert("Ваш результат на экране.");
                        }
                    } else {
                        questionBlocks[now].style.display = "none";
                        now++;
                        rightCount += this.nowRight;
                        questionBlocks[now].style.display = "block";
                    }
                }
            }
            
        </script>
	  <div id="navcontainer">
        </div>
      <p></p>
    </div>
    <div id="content">
      <h2>
      </h2>
    </div>
  </div>
</div>
<div id="footer">
  

</body>
</html>
Ответить с цитированием
  #2 (permalink)  
Старый 09.04.2014, 08:57
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,124

Сообщение от doom2154
есть тэст ...
Он формируется серверным языком? Или контент кто-то пишет руками?
Ответить с цитированием
  #3 (permalink)  
Старый 09.04.2014, 10:48
Интересующийся
Отправить личное сообщение для titan1993 Посмотреть профиль Найти все сообщения от titan1993
 
Регистрация: 04.11.2013
Сообщений: 14

Школолоша, сначала пойми как верстать, а уж потом берись за javascript
Сообщение от doom2154 Посмотреть сообщение
Всем привет, возник вопрос помогите пжл- есть тэст но немогу понять как сделать так чтобы он различал правильные и не правильные ответы помогите пжл и правильный код, тоесть надо сделать так чтобы скрипт отбирал правильный ответ и отсеивал его потом писал какое кол-во ответов правильно и не правильно.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type = "text/css">
            div.questionBlock {
                display: block; /*ЗАЧЕМ none???*/
            }
        </style>
        <script type="text/javascript">
			$(function(){
				$('.questionForm input[type=submit]').on('click', function(e){
					alert('ss');
					return false
				})
			})
		</script>
<title> Сборка ПК - Контактная информация </title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="wrap">
  <div id="masthead">
    <h1>Все о сборке ПК</h1>
    <div id="menucontainer">
      <div id="menunav">
        <ul>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Главная.html"><span>Главная</span></a></li>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Обучение.html"><span>Обучение</span></a></li>
          <li><a href="F:\Web-Сайт\[url]www.sborka-pk.ru\Контактная[/url] информация.html" class="current"><span>Контактная информация  </span></a></li>
        </ul>
       </div>
    </div>
  </div>
  <br>
  <font size="+2"><p align="center">
	  Тест по теме: Знакомство с ПК и его составными</font></p>
	  <div class = "questionBlock">
	  <font size="+1">
			
			<br>
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
				
				<form method="POST" action="test.php" class="questionForm">
				
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			
			<!--!!!!!!!!!!!!!!!!!!!!!Добавить атрибут 'value' ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
				Вопрос 1:<br>
				<input type = "radio" name="q1" value="0" onclick="qa.nowRight = 0">1<br>
				<input type = "radio" name="q1" value="1" onclick="qa.nowRight = 1">2<br>
				<input type = "radio" name="q1" value="0" onclick="qa.nowRight = 0">3<br>
				<input type = "radio" name="q1" value="0" onclick="qa.nowRight = 0">4<br>
				
				<br>
				Вопрос 2:<br>
				<input type = "radio" name="q2" value="1" onclick="qa.nowRight = 1">1)<br>
				<input type = "radio" name="q2" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q2" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q2" value="0" onclick="qa.nowRight = 0">4)<br> 
					
				<br>
				Вопрос 3:<br>
				<input type = "radio" name="q3" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q3" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q3" value="1" onclick="qa.nowRight = 1">3)<br>
				<input type = "radio" name="q3" value="0" onclick="qa.nowRight = 0">4)<br> 
						
				<br>
				Вопрос 4:<br>
				<input type = "radio" name="q4" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q4" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q4" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q4" value="1" onclick="qa.nowRight = 1">4)<br> 
						
				<br>
				Вопрос 5:<br>
				<input type = "radio" name="q5" value="1" onclick="qa.nowRight = 1">1)<br>
				<input type = "radio" name="q5" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q5" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q5" value="0" onclick="qa.nowRight = 0">4)<br> 
						
				<br>
				Вопрос 6:<br>
				<input type = "radio" name="q6" value="1" onclick="qa.nowRight = 1">1)<br>
				<input type = "radio" name="q6" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q6" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q6" value="0" onclick="qa.nowRight = 0">4)<br> 
							
				<br>
				Вопрос 7:<br>
				<input type = "radio" name="q7" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q7" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q7" value="1" onclick="qa.nowRight = 1">3)<br>
				<input type = "radio" name="q7" value="0" onclick="qa.nowRight = 0">4)<br> 
						
				<br>
				Вопрос 8:<br>
				<input type = "radio" name="q8" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q8" value="1" onclick="qa.nowRight = 1">2)<br>
				<input type = "radio" name="q8" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q8" value="0" onclick="qa.nowRight = 0">4)<br> 
					
				<br>
				Вопрос 9:<br>
				<input type = "radio" name="q9" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q9" value="1" onclick="qa.nowRight = 1">2)<br>
				<input type = "radio" name="q9" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q9" value="0" onclick="qa.nowRight = 0">4)<br> 
						
				<br>
				<br>
				Вопрос 10:<br>
				<input type = "radio" name="q10" value="0" onclick="qa.nowRight = 0">1)<br>
				<input type = "radio" name="q10" value="0" onclick="qa.nowRight = 0">2)<br>
				<input type = "radio" name="q10" value="0" onclick="qa.nowRight = 0">3)<br>
				<input type = "radio" name="q10" value="1" onclick="qa.nowRight = 1">4)<br> 
				
				
				
				
				<br>
				
				
				<!--<input type="button" value="Ответить"  onclick="qa.nextOrResult()">  НЕПРАВИЛЬНО!!!!!!!!!-->
				<input type="submit" value="ОТПРАВИТЬ" name="submit" />
			<!--!!!!!!!!!!!!!!!!!!!!!Добавить атрибут 'value' ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			</form>
			</font>
				</div>
			
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			
			
		<script type = "text/javascript">
            /*var qa = new QuestAnalizer();
            function QuestAnalizer() {
                var now = 0, printed = false, rightCount = 2;
                var questionBlocks = document.querySelectorAll("div.questionBlock");
                var allQCount = questionBlocks.length;
                this.nowRight = 0;
                questionBlocks[now].style.display = "block";
                this.nextOrResult = function () {
                    if (now >= allQCount-1) {
                        now++;
                        if (!printed) {
                            questionBlocks[now - 1].style.display = "none"
                            var p = document.createElement("p");
                            p.innerHTML = "Верных ответов " + rightCount + ". Вы набрали " + (rightCount / allQCount * 100).toFixed(0) + "%";
                            document.body.appendChild(p);
                            printed = true;
                        } else {
                            alert("Ваш результат на экране.");
                        }
                    } else {
                        questionBlocks[now].style.display = "none";
                        now++;
                        rightCount += this.nowRight;
                        questionBlocks[now].style.display = "block";
                    }
                }
            }
            */
        </script>
	  <div id="navcontainer">
        </div>
      <p></p>
    </div>
    <div id="content">
      <h2>
      </h2>
    </div>
  </div>
</div>
<div id="footer">
  

</body>
</html>
Исправьте структуру для начала, скрипт писать уже нет желания!!!

Последний раз редактировалось titan1993, 09.04.2014 в 11:04.
Ответить с цитированием
  #4 (permalink)  
Старый 09.04.2014, 14:07
Новичок на форуме
Отправить личное сообщение для doom2154 Посмотреть профиль Найти все сообщения от doom2154
 
Регистрация: 08.04.2014
Сообщений: 2

Помоги пжл очень надо
Ответить с цитированием
  #5 (permalink)  
Старый 09.04.2014, 15:40
Интересующийся
Отправить личное сообщение для titan1993 Посмотреть профиль Найти все сообщения от titan1993
 
Регистрация: 04.11.2013
Сообщений: 14

Дальше уже сами пишите. Лайк если помог.
Дальше уже сами пишите. Лайк если помог.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type = "text/css">
            div.questionBlock {
                display: block; /*ЗАЧЕМ none???*/
            }
        </style>
        <script type="text/javascript">
			$(function(){
				
				$('.questionForm input[type=submit]').on('click', function(e){
					var answer=0;
					for(i=0;i<$('.group').length;i++){
						$('.group').eq(i).each(function(id, elem){
							if($(elem).find('input:checked').length!=0){
								if($(elem).find('input:checked').attr('value')==1){
									answer++;
								}
							}
						})
					}
					alert("Тест пройден на: "+(answer/$('.group').length)*100+'%')
					return false
				})
			})
		</script>
<title> Сборка ПК - Контактная информация </title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="wrap">
  <div id="masthead">
    <h1>Все о сборке ПК</h1>
    <div id="menucontainer">
      <div id="menunav">
        <ul>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Главная.html"><span>Главная</span></a></li>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Обучение.html"><span>Обучение</span></a></li>
          <li><a href="F:\Web-Сайт\[url]www.sborka-pk.ru\Контактная[/url] информация.html" class="current"><span>Контактная информация  </span></a></li>
        </ul>
       </div>
    </div>
  </div>
  <br>
  <font size="+2"><p align="center">
	  Тест по теме: Знакомство с ПК и его составными</font></p>
	  <div class = "questionBlock">
	  <font size="+1">
			
			<br>
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
				
				<form method="POST" action="test.php" class="questionForm">
				
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			
			<!--!!!!!!!!!!!!!!!!!!!!!Исправить атрибут 'name' ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
				<div class="group">
					Вопрос 1:<br>
					<input type = "radio" name="q1" value="0">1<br>
					<input type = "radio" name="q1" value="1">2<br>
					<input type = "radio" name="q1" value="0">3<br>
					<input type = "radio" name="q1" value="0">4<br>
					<input type = "radio" name="q1" value="0">5<br>
					<input type = "radio" name="q1" value="0">6<br>
				</div>
				
				<br>
				<div class="group">
					Вопрос 2:<br>
					<input type = "radio" name="q2" value="1">1)<br>
					<input type = "radio" name="q2" value="0">2)<br>
					<input type = "radio" name="q2" value="0">3)<br>
					<input type = "radio" name="q2" value="0">4)<br> 
					<input type = "radio" name="q2" value="0">5)<br> 
				</div>	
				<br>
				<div class="group">
					Вопрос 3:<br>
					<input type = "radio" name="q3" value="0">1)<br>
					<input type = "radio" name="q3" value="0">2)<br>
					<input type = "radio" name="q3" value="1">3)<br>
				</div>		
				<br>
				<div class="group">
					Вопрос 4:<br>
					<input type = "radio" name="q4" value="0">1)<br>
					<input type = "radio" name="q4" value="0">2)<br>
					<input type = "radio" name="q4" value="0">3)<br>
					<input type = "radio" name="q4" value="1">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 5:<br>
					<input type = "radio" name="q5" value="1">1)<br>
					<input type = "radio" name="q5" value="0">2)<br>
					<input type = "radio" name="q5" value="0">3)<br>
					<input type = "radio" name="q5" value="0">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 6:<br>
					<input type = "radio" name="q6" value="1">1)<br>
					<input type = "radio" name="q6" value="0">2)<br>
					<input type = "radio" name="q6" value="0">3)<br>
					<input type = "radio" name="q6" value="0">4)<br> 
				</div>			
				<br>
				<div class="group">
					Вопрос 7:<br>
					<input type = "radio" name="q7" value="0">1)<br>
					<input type = "radio" name="q7" value="0">2)<br>
					<input type = "radio" name="q7" value="1">3)<br>
					<input type = "radio" name="q7" value="0">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 8:<br>
					<input type = "radio" name="q8" value="0">1)<br>
					<input type = "radio" name="q8" value="1">2)<br>
					<input type = "radio" name="q8" value="0">3)<br>
					<input type = "radio" name="q8" value="0">4)<br> 
				</div>	
				<br>
				<div class="group">
					Вопрос 9:<br>
					<input type = "radio" name="q9" value="0">1)<br>
					<input type = "radio" name="q9" value="1">2)<br>
					<input type = "radio" name="q9" value="0">3)<br>
					<input type = "radio" name="q9" value="0">4)<br> 
				</div>		
				<br>
				<br>
				<div class="group">
					Вопрос 10:<br>
					<input type = "radio" name="q10" value="0">1)<br>
					<input type = "radio" name="q10" value="0">2)<br>
					<input type = "radio" name="q10" value="0">3)<br>
					<input type = "radio" name="q10" value="1">4)<br> 
				</div>
				
				
				
				<br>
				
				
				<!--<input type="button" value="Ответить"  onclick="qa.nextOrResult()">  НЕПРАВИЛЬНО!!!!!!!!!-->
				<input type="submit" value="ОТПРАВИТЬ" name="submit" />
			<!--!!!!!!!!!!!!!!!!!!!!!Исправить атрибут 'name' ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			</form>
			</font>
				</div>
			
			<!--!!!!!!!!!!!!!!!!!!!!!НАПИСАТЬ ОБЯЗАТЕЛЬНО!!!!!!!!!!!!!!!!!!!!!!-->
			
			
			
		<script type = "text/javascript">
            /*var qa = new QuestAnalizer();
            function QuestAnalizer() {
                var now = 0, printed = false, rightCount = 2;
                var questionBlocks = document.querySelectorAll("div.questionBlock");
                var allQCount = questionBlocks.length;
                this.nowRight = 0;
                questionBlocks[now].style.display = "block";
                this.nextOrResult = function () {
                    if (now >= allQCount-1) {
                        now++;
                        if (!printed) {
                            questionBlocks[now - 1].style.display = "none"
                            var p = document.createElement("p");
                            p.innerHTML = "Верных ответов " + rightCount + ". Вы набрали " + (rightCount / allQCount * 100).toFixed(0) + "%";
                            document.body.appendChild(p);
                            printed = true;
                        } else {
                            alert("Ваш результат на экране.");
                        }
                    } else {
                        questionBlocks[now].style.display = "none";
                        now++;
                        rightCount += this.nowRight;
                        questionBlocks[now].style.display = "block";
                    }
                }
            }
            */
        </script>
	  <div id="navcontainer">
        </div>
      <p></p>
    </div>
    <div id="content">
      <h2>
      </h2>
    </div>
  </div>
</div>
<div id="footer">
  

</body>
</html>
Ответить с цитированием
  #6 (permalink)  
Старый 09.04.2014, 21:33
Интересующийся
Отправить личное сообщение для titan1993 Посмотреть профиль Найти все сообщения от titan1993
 
Регистрация: 04.11.2013
Сообщений: 14

Вот вариант с оценками, значения можешь поставить сам
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script type="text/javascript">
			$(function(){
				
				$('.questionForm input[type=submit]').on('click', function(e){
					var answer=0;
					for(i=0;i<$('.group').length;i++){
						$('.group').eq(i).each(function(id, elem){
							if($(elem).find('input:checked').length!=0){
								if($(elem).find('input:checked').attr('value')==1){
									answer++;
								}
							}
						})
					}
					var general = (answer/$('.group').length)*100;
					var text = '';
					console.log(general);
					switch (true){
						case general >= 75:
							text = 'Молодец, 5!';
							alert(text + " Тест пройден на: "+general + "%");
							break;
						case general >= 60:
							text = 'Молодец, 4!';
							alert(text + " Тест пройден на: "+general + "%");
							break;						
						case general >= 50:
							text = 'Молодец, 3!';
							alert(text + " Тест пройден на: "+general + "%");
							break;
						case general < 50:
							text = 'Плохо, 2!';
							alert(text + " Тест пройден на: "+general + "%");
							break;
					}
					return false
				})
			})
		</script>
<title> Сборка ПК - Контактная информация </title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="wrap">
  <div id="masthead">
    <h1>Все о сборке ПК</h1>
    <div id="menucontainer">
      <div id="menunav">
        <ul>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Главная.html"><span>Главная</span></a></li>
          <li><a href="F:\Web-Сайт\www.sborka-pk.ru\Обучение.html"><span>Обучение</span></a></li>
          <li><a href="F:\Web-Сайт\[url]www.sborka-pk.ru\Контактная[/url] информация.html" class="current"><span>Контактная информация  </span></a></li>
        </ul>
       </div>
    </div>
  </div>
  <br>
  <font size="+2"><p align="center">
	  Тест по теме: Знакомство с ПК и его составными</font></p>
	  <div class = "questionBlock">
	  <font size="+1"><br>
			<form method="POST" action="test.php" class="questionForm">
				<div class="group">
					Вопрос 1:<br>
					<input type = "radio" name="q1" value="0">1<br>
					<input type = "radio" name="q1" value="1">2<br>
					<input type = "radio" name="q1" value="0">3<br>
					<input type = "radio" name="q1" value="0">4<br>
					<input type = "radio" name="q1" value="0">5<br>
					<input type = "radio" name="q1" value="0">6<br>
				</div>
				
				<br>
				<div class="group">
					Вопрос 2:<br>
					<input type = "radio" name="q2" value="1">1)<br>
					<input type = "radio" name="q2" value="0">2)<br>
					<input type = "radio" name="q2" value="0">3)<br>
					<input type = "radio" name="q2" value="0">4)<br> 
					<input type = "radio" name="q2" value="0">5)<br> 
				</div>	
				<br>
				<div class="group">
					Вопрос 3:<br>
					<input type = "radio" name="q3" value="0">1)<br>
					<input type = "radio" name="q3" value="0">2)<br>
					<input type = "radio" name="q3" value="1">3)<br>
				</div>		
				<br>
				<div class="group">
					Вопрос 4:<br>
					<input type = "radio" name="q4" value="0">1)<br>
					<input type = "radio" name="q4" value="0">2)<br>
					<input type = "radio" name="q4" value="0">3)<br>
					<input type = "radio" name="q4" value="1">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 5:<br>
					<input type = "radio" name="q5" value="1">1)<br>
					<input type = "radio" name="q5" value="0">2)<br>
					<input type = "radio" name="q5" value="0">3)<br>
					<input type = "radio" name="q5" value="0">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 6:<br>
					<input type = "radio" name="q6" value="1">1)<br>
					<input type = "radio" name="q6" value="0">2)<br>
					<input type = "radio" name="q6" value="0">3)<br>
					<input type = "radio" name="q6" value="0">4)<br> 
				</div>			
				<br>
				<div class="group">
					Вопрос 7:<br>
					<input type = "radio" name="q7" value="0">1)<br>
					<input type = "radio" name="q7" value="0">2)<br>
					<input type = "radio" name="q7" value="1">3)<br>
					<input type = "radio" name="q7" value="0">4)<br> 
				</div>		
				<br>
				<div class="group">
					Вопрос 8:<br>
					<input type = "radio" name="q8" value="0">1)<br>
					<input type = "radio" name="q8" value="1">2)<br>
					<input type = "radio" name="q8" value="0">3)<br>
					<input type = "radio" name="q8" value="0">4)<br> 
				</div>	
				<br>
				<div class="group">
					Вопрос 9:<br>
					<input type = "radio" name="q9" value="0">1)<br>
					<input type = "radio" name="q9" value="1">2)<br>
					<input type = "radio" name="q9" value="0">3)<br>
					<input type = "radio" name="q9" value="0">4)<br> 
				</div>		
				<br>
				<br>
				<div class="group">
					Вопрос 10:<br>
					<input type = "radio" name="q10" value="0">1)<br>
					<input type = "radio" name="q10" value="0">2)<br>
					<input type = "radio" name="q10" value="0">3)<br>
					<input type = "radio" name="q10" value="1">4)<br> 
				</div><br>
				<input type="submit" value="ОТПРАВИТЬ" name="submit" />
			</form>
			</font>
				</div>
	  <div id="navcontainer">
        </div>
      <p></p>
    </div>
    <div id="content">
      <h2>
      </h2>
    </div>
  </div>
</div>
<div id="footer">
  

</body>
</html>
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
задача из VBA сделанная в Java Script Katya1406 Javascript под браузер 1 02.12.2014 19:34
задача из VBA сделанная в Java Script Katya1406 Элементы интерфейса 0 04.03.2014 00:07
Требуется программист Java Script Дитрий Андрияшкин Работа 0 03.08.2011 21:44
[Оптимизация] Тест написанный javascripts TBIKC Общие вопросы Javascript 3 18.05.2011 11:27
HELP: Java Script Error: “text” is undefined Aram Khachaturyan Общие вопросы Javascript 2 11.04.2008 16:57