コード

[source] [reload]

参考文献

使い方

<script type="text/javascript">
var spinYear;
var spinMonth;
var spinDay;

window.onload = function() {
  var now = new Date();
  spinYear = new SpinControll('year', now.getFullYear(), 2000, 2100);
  spinMonth = new SpinControll('month', now.getMonth()+1, 1, 12);
  spinDay = new SpinControll('day', now.getDate(), 1, 31);
  
  spinMonth.onChange = function(val) {
    switch(val) {
    case 2:
      spinDay.setMaxValue( isLeapYear(spinYear.getVal()) ? 29 : 28 );
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      spinDay.setMaxValue( 30 );
      break;
    default:
      spinDay.setMaxValue( 31 );
    }
  }
}

function isLeapYear(year) {
  if ( year % 400 == 0) {
    return true;
  }
  if ( year % 100 == 0) {
    return false;
  }
  if ( year % 4 == 0) {
    return true;
  }
  return false;
}

function getValues() {
  alert(spinYear.getVal() + "-" + spinMonth.getVal() + "-" + spinDay.getVal());
}
</script>
<body>
<table border="0">
  <tr><td><div id="year"></div></td>
  <td>年</td>
  <td><div id="month"></div></td>
  <td>月</td>
  <td><div id="day"></div></td>
  <td>日</td>
</tr></table>
<input type="button" onclick="getValues()" value="値の取得"/>
</body>
</head>

HTML


添付ファイル: filespin_control_buttons.png 1483件 [詳細] filespin.html 3253件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2011-06-03 (金) 22:00:28 (4709d)
Short-URL: https://at-sushi.com:443/pukiwiki/index.php?cmd=s&k=557941817c
ISBN10
ISBN13
9784061426061