29. 드롭다운리스트체크(selectedIndex 사용)
.NET프로그래밍/JavaScript 1.2 2009. 8. 11. 16:03 |<!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>
<title></title>
<script type="text/javascript">
function CheckSelect() {
if (document.getElementById("lstFavorite").selectedIndex == 0) {
alert("관심사항을 선택하시오.");
document.getElementById("lstFavorite").focus();
}
else {
window.alert("당신의 관심사항 : " + document.getElementById("lstFavorite").value);
}
}
</script>
</head>
<body>
관심사항<br />
<select id="lstFavorite">
<option value="">- 선택 -</option>
<option value="C#">C#</option>
<option value="ASP.NET">ASP.NET</option>
<option value="Sliverlight">Silverlight</option>
</select>
<input type="button" value="확인" onclick="CheckSelect();" />
</body>
</html>
'.NET프로그래밍 > JavaScript 1.2' 카테고리의 다른 글
31. 이벤트(Event) (0) | 2009.08.13 |
---|---|
30. 자바스크립트에서 스타일시트 접근 (0) | 2009.08.11 |
28. 폼(form)객체 - 2 (0) | 2009.08.11 |
27. 폼(form) 객체 - 입력 값에 대한 유효성 검사 (0) | 2009.08.11 |
26. 히스토리(history) 객체 (0) | 2009.08.11 |