2015-01-06 9 views
1

나는 이것이 세상에서 가장 쉬운 일이라고 생각합니다. 난 그냥 onclick 전화 버튼을 만들고 자바 스크립트를 실행하고 싶습니다. 그러나 내가 할 때마다 잡히지 않은 TypeError : undefined가 함수가 아닙니다 오류.버튼 onclick 정의되지 않은 함수가 아닙니다.

나는 이것을 읽었지만 그 기능을 찾을 수없는 이유를 이해하지 못하는 것 같습니다.

요약 : 버튼을 누르면 ThePush()가 실행되지만 콘솔에 오류가 발생합니다.

코드 :

<!DOCTYPE html> 
<html> 
<head> 
<script type="text/javascript"> 

     function ThePush() { 
      var name = document.getElementByID('name').value; 
      var pl = document.getElementByID('PL1').value; 
      var plw = document.getElementByID('theplw').value; 
      var al = document.getElementByID('theal').value; 
      //do stuff with these variables. 
     } 

</script> 
</head> 
<body> 
<b>Player One: </b><input id="name" type="text" value="Name"></input> 
<br/><b>Level: </b><input id="PL1" style="width:50px" type="text" id="PL1L" value="0" readonly></input> 
<br/> 
<button id="thesub" onclick="ThePush();">Submit</button> 

<select id="theplw"> 
<option value="A: 0-999">A: 0-999</option> 
<option value="B: 1,000-9,999">B: 1,000-9,999</option> 
<option value="C: 10,000-99,999">C: 10,000-99,999</option> 
<option value="D: 100,000-499,999">D: 100,000-499,999</option> 
<option value="E: 500,000-1,499,999">E: 500,000-1,499,999</option> 
<option value="F: 1,500,000+">F: 1,500,000+</option></select> 
<br/><b>Sub Level: </b><input id="theal" style="width:50px" type="text" id="AL1L" value="0" readonly></input> 
<hr> 
<iframe src="others.php" frameborder="0" width="500"></iframe> 
<iframe id="updater" src="update.php" frameborder="0" width="0" height="0"></iframe> 

</body> 
</html> 

어떤 생각이? 당신의 도움에 미리 감사드립니다!

+0

javascript에는 getElementByID라는 것이 아무것도 없습니다. 'getElementById', NOT'초 getElementByID' : :''하지''(자기 닫는 태그), 셋째 : 그냥
'같은'


'(자기 폐쇄를 당신은'getElementById.' –

+0

첫째을 사용하는 가정된다 '), 넷째 :'' 태그를 다룰 때 label 태그를 사용해야합니다; 자세한 내용은 http://www.w3schools.com/tags/tag_label.asp -> "

답변

5

찾고 있습니다.

+2

정확합니다. 한숨, 어리석은 실수. – AtlasOnEarth

2

귀하의 onclick은 괜찮지 만 getElementByID은 (는) 기능이 아니며 오류가 발생했습니다. 당신은 당신이 getElementById하지 getElementByID에 메소드 이름을 변경해야합니다 getElementById

function ThePush() { 
     var name = document.getElementById('name').value; 
     var pl = document.getElementById('PL1').value; 
     var plw = document.getElementById('theplw').value; 
     var al = document.getElementById('theal').value; 
     //do stuff with these variables. 
    } 
+1

당신은 틀린 품목입니다. 내 바보 같은 실수 야. – AtlasOnEarth

관련 문제