AJAX, JavaScript, XML, PHP ... 모든게 서툰 나를 위하여 고른책
진짜 하루에 10분씩 한챕터씩만 보고있지만 저자의 쉬운 풀이가 팍팍 와닿는 그동안 알고있던내용들이랑 취합해나갈 수있는 우선 맛보기 클래스로 딱좋은것같은 책이다.
오늘은 JavaScript를 코딩해봤는데.
마지막 예제가 안된다.ㅠ
function 으로 1과 10사이에 숫자를 체크하여 범위를 벗어나면
alert를 뿌려줘야하는데 onSubmit 이벤트가 그냥 action 주소로 보내버린다.
뭐가 잘못된건지 찾지 못한채...흑!
자바스크립트도 뭐~ 어렵진않네!!ㅋㅋ 라는 마음으로 오늘은 이만!
== 자주사용되는 이벤트 처리기 onChange 입력필드가 수정될 때
onClick 사용자가 해당 구성 요소를 클릭했을때
onLoad 웹 페이지의 로드가 완료될 때
onMouseOver 마우스 커서가 해당 구성 요소의 영역 안으로 진입할 때
onMouseOut 마우스 커서가 해당 구성 요소의 밖으로 나갈 때
onSubmit 전송 버튼을 눌렀을 때
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>A simple HTML Document </title>
<script language="JavaScript" type="text/javascript">
function showAlert(message)
{
alert(message)
}
</script>
</head>
<body bgcolor = "#cccccc">
<center>
<image src="http://cfs12.tistory.com/image/19/tistory/2009/01/06/00/55/49622d7a199e5" border="2" onMouseOver ="showAlert('A pictur of Seville')" alt="hello!!"/>
<h1> Guide to Seville</h1>
<h3>A brief guide to the attractions</h3>
<table border = "2">
<tr>
<th bgcolor = "#aaaaaa">Attraction</th>
<th bgcolor = "#aaaaaa">Description</th>
</tr>
<tr>
<td>Cathedral</td>
<td>Dating back to the 15rh century</td>
</tr>
<tr>
<td>Alcazar</td>
<td>The medieval Islamic palace</td>
</tr>
</table>
<p>Enjoy your stay in beautiful Sevile.</p>
<script language="JavaScript" type ="text/javascript">
document.writeln("This line was written using JavaScript!");
</script>
<form>
<input type ="button" value="Click Here" onClick="showAlert('Thanks for clicking!')">
</form>
</center>
</body>
</html>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>A simple HTML Document </title>
<script language="JavaScript" type="text/javascript">
function numcheck()
{
var numentered = document.form1.usernumber.value;
if((numentered>=1) && (numentered<=10))
{
alert(" Please try again.");
return true;
}else
{
alert("Your entry was invalid. Please try again.");
return false;
}
}
</script>
</head>
<body bgcolor = "#cccccc">
<center>
<form name ="form1" action="http://updownme.tistory.com" method="post" onSubmit="return numcheck()">
Enter a number from 1 to 10 :
<input size="4" type="text" name ="usernumber">
<input type="submit" value="Enter">
</form>
</center>
</body>
</html>