Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <select id="year" name="year"></select>
<select id="month" name="month"></select>
<select id="date" name="date"></select>
              
            
!

CSS

              
                
              
            
!

JS

              
                (function() {
	// ライブラリ
	/**
	 * 任意の年が閏年であるかをチェックする
	 * @param {number} チェックしたい西暦年号
	 * @return {boolean} 閏年であるかを示す真偽値
	 */
  const isLeapYear = year => (year % 4 === 0) && (year % 100 !== 0) || (year % 400 === 0);

  /**
   * 任意の年の2月の日数を数える
   * @param {number} チェックしたい西暦年号
   * @return {number} その年の2月の日数
   */
  const countDatesOfFeb = year => isLeapYear(year) ? 29 : 28;

  /**
   * セレクトボックスの中にオプションを生成する
   * @param {string} セレクトボックスのDOMのid属性値
   * @param {number} オプションを生成する最初の数値
   * @param {number} オプションを生成する最後の数値
   * @param {number} 現在の日付にマッチする数値
   */
  const createOption = (id, startNum, endNum, current) => {
    const selectDom = document.getElementById(id);
    let optionDom = '';
    for (let i = startNum; i <= endNum; i++) {
      if (i === current) {
        option = '<option value="' + i + '" selected>' + i + '</option>';
      } else {
        option = '<option value="' + i + '">' + i + '</option>';
      }
      optionDom += option;
    }
    selectDom.insertAdjacentHTML('beforeend', optionDom);
  }

  // DOM
  const yearBox = document.getElementById('year');
  const monthBox = document.getElementById('month');
  const dateBox = document.getElementById('date');

  // 日付データ
  const today = new Date();
  const thisYear = today.getFullYear();
  const thisMonth = today.getMonth() + 1;
  const thisDate = today.getDate();

  let datesOfYear= [31, countDatesOfFeb(thisYear), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

  // イベント
  monthBox.addEventListener('change', (e) => {
		dateBox.innerHTML = '';
		const selectedMonth = e.target.value;
		createOption('date', 1, datesOfYear[selectedMonth - 1], 1);
	});

	yearBox.addEventListener('change', e => {
		monthBox.innerHTML = '';
		dateBox.innerHTML = '';
		const updatedYear = e.target.value;
		datesOfYear = [31, countDatesOfFeb(updatedYear), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

		createOption('month', 1, 12, 1);
	  createOption('date', 1, datesOfYear[0], 1);
	});

	// ロード時
	createOption('year', 1900, thisYear, thisYear);
  createOption('month', 1, 12, thisMonth);
  createOption('date', 1, datesOfYear[thisMonth - 1], thisDate);
})();
              
            
!
999px

Console