Demo: Add Month Options and Select the Current Month

The dropdown is populated from an array, then its value is set to the current month.

The original demo made its source available to users. The complete JavaScript and HTML used here remain available below.

JavaScript Used in This Demo Top ↑

const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const monthList = document.getElementById("monthList");
months.forEach((month) => monthList.add(new Option(month, month)));
monthList.value = months[new Date().getMonth()];

HTML Used in This Demo Top ↑

<form action="yourpage.php" method="post">
  <label for="monthList">Month</label>
  <select id="monthList" name="Month_list">
    <option value="">Month list</option>
  </select>
</form>

Adding options tutorial · Listbox · Date, month and year projects




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer