본문 바로가기

개발하자/자바스크립트

선택한 년월을 이용하여 요일구하기

<html>
 <head>
 <script>
 window.onload=function(){
 b.onclick=function(){
var b=["일","월","화","수","목","금","토"];
var s=new Date(y.value,m.value-1,1);
con.innerHTML=y.value+"년"+m.value+"월"+"1일"+b[s.getDay()]+"요일";
 }
 }
 </script>
 </head>
 <body>
 <select id="y">
 <script>
 for(var a=1900; a<2050; a++){
 document.write("<option>"+a+"</option>");
 }
 </script>
 </select>년

<select id="m">
 <script>
 for(var a=1; a<13; a++){
 document.write("<option>"+a+"</option>");
 }
 </script>
 </select>월
<input type="button" id="b" value="달력보기">
 <div id="con"></div>
 </body>
</html>