2014-11-15 3 views
0

포럼을 확인한 결과 내 문제에 직접적으로 도움이되거나 관련이있는 항목을 찾을 수 없으므로 여기를 클릭하십시오. 저는 학교에서 게임을하고 있어요. 플레이어는 3 개의 클래스를 보여 주며, 각각 옆에 라디오 버튼이 있습니다. 나는 라디오 버튼을 클릭 할 수 있기를 원한다. 그리고 마지막 결정 (어떤 클래스가 될 것인가)을 한 후에, 맨 아래의 버튼을 클릭하면 게임이 진행될 것이다.자바 스크립트 : 선택한 라디오 버튼을 확인하십시오.

<html> 

<head> 
    <meta charset="utf-8"> 
    <title>Class Select</title> 
</head> 
<link rel="icon" type="image/x-icon" href="icon.ico"> 

<body background="bg2.jpg"> 

<p align="center"><font size="20" face="verdana" color="white" ><b><u>Select a Class</u></b> </font></p> 
<br><br> 

<div align="middle"> 

<!-- Angel --> 
<img src="angel.png" height="110" width="110" alt="The Angel Class"> 
<input type="radio" size="20" name="class" class="big" value="Angel" id="class_angel"> 
<p><font color="aquamarine" size="8"><b>The Angel</b></font></p> 
<p><font color="aquamarine" size="6">A born fighter, for all that is good in the world.</font>  </p> 
<br> 
<p><font color="darkcyan" size="6"><b>Health: 10</b></font></p> 
<p><font color="darkcyan" size="6"><b>Damage: 6</b></font></p> 
<p><font color="darkcyan" size="6"><b>Starting Item: Halo</b></font></p> 
<p><font color="darkcyan" size="4"><b>(Chance of doing double damage when on less than 5 health) 

    </b></font></p> 
<br><br> 

<!-- Beast --> 
<img src="beast.png" height="110" width="110" alt="The Beast Class"> 
<input type="radio" size="20" name="class" class="big" value="Beast" id="class_beast"> 
<p><font color="brown" size="8"><b>The Beast</b></font></p> 
<p><font color="brown" size="6">Savage at heart, teeth and mind.</font></p> 
<br> 
<p><font color="burlywood" size="6"><b>Health: 15</b></font></p> 
<p><font color="burlywood" size="6"><b>Damage: 4</b></font></p> 
<p><font color="burlywood" size="6"><b>Starting Item: Golden Ring</b></font></p> 
<p><font color="burlywood" size="4"><b>(Chance of finding more gold)</b></font></p> 
<br><br> 

<!-- Spirit --> 
<img src="spirit.png" height="110" width="110" alt="The Spirit Class"> 
<input type="radio" size="20" name="class" class="big" value="Spirit" id="class_spirit"> 
<p><font color="papayawhip" size="8"><b>The Spirit</b></font></p> 
<p><font color="papayawhip" size="6">Easier to see through his lies.</font></p> 
<br> 
<p><font color="thistle" size="6"><b>Health: 5</b></font></p> 
<p><font color="thistle" size="6"><b>Damage: 10</b></font></p> 
<p><font color="thistle" size="6"><b>Starting Item: Wandering Soul</b></font></p> 
<p><font color="thistle" size="4"><b>(Chance of draining an enemies life)</b></font></p> 
<br><br> 

<img onclick="continueCheck()" src="next.png" alt="Continue" class="button"> 

</div> 

<style type="text/css" media="screen"> 
.big{ width: 8em; height: 8em; } 
.medium{ width: 16em; height: 8em; } 
.button{ width: 6em; height:6em; } 
</style> 


<!-- Scripting --> 
<script type="text/javascript"> 
function continueCheck() 
{ 
    if(document.getElementById("class_angel") value="Angel") 
    { 
     console.log("You pressed Angel"); 
    }else if(document.getElementById("class_beast") value="Beast") 
    { 
     console.log("You pressed Beast"); 
    }else if(document.getElementById("class_spirit") value="Spirit") 
    { 
     console.log("You pressed Spirit"); 
    } 
} 
</script> 

</body> 

</html> 

태그 하단의 영역이 작동하지 않는 것 같습니다. 나는 오류를 "continueCheck은 VM68 classSelect.html을 정의되지 않은 : catch되지 않은 ReferenceError가 52"얻을

귀하의 구문은 모든 올려요있다

답변

0

:

if(document.getElementById("class_angel") value="Angel") 

당신이 임의의이 방법을 볼 ")"의 끝에서 너 줄?

편집 : 내 생각 엔 당신 아마 쓰는 의미 :

function continueCheck() 
{ 
    if(document.getElementById("class_angel").checked) 
    { 
     console.log("You pressed Angel"); 
    } 
    else if(document.getElementById("class_beast").checked) 
    {  
     console.log("You pressed Beast"); 
    } 
    else if(document.getElementById("class_spirit").checked) 
    { 

     console.log("You pressed Spirit"); 
    } 
} 
+0

작품을 완벽하게. 고마워요, 한 무리의 아퀴나! – String

관련 문제