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.
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()];
<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
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.