Month Selection Menu

Save time on forms. This script creates a dropdown menu and intelligently pre-selects the user's current month.

The current month is automatically selected.

Copy the Script

<select id="months"></select>

<script>
var monthNames = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
];

var d = new Date();
var currentMonth = d.getMonth(); // 0 - 11
var select = document.getElementById("months");

for (var i = 0; i < monthNames.length; i++) {
    var option = document.createElement("option");
    option.text = monthNames[i];
    option.value = i + 1; // Value 1-12
    
    if (i === currentMonth) {
        option.selected = true;
    }
    
    select.add(option);
}
</script>

Frequently Asked Questions

Using JavaScript allows you to automatically select the current month without updating the code. It also supports localization (translating month names) more easily.

Yes. You can edit the `monthNames` array to use 'Jan', 'Feb', etc., or use `toLocaleString` with `{month: 'short'}`.

Absolutely. It works perfectly alongside Day and Year dropdowns for DOB selection forms.