Skip to content
Advertisement

Showing dates on HTML on option select

I am working on an HTML file that has a drop-down list of months. When I select a month, I want the function to show the dates of the month on the page in this format:

1st of December 2020
2nd of December 2020
.
.
.
31st of December 2020

Below is my html:

I cannot get the function to execute on option select. Could you help me what is wrong with the script? I am no expert in javascript yet but I am continuously exploring and experimenting with HTML and javascript.

Please note that I will be add the codes for the other months when I get the function to execute for these two months.

JavaScript
JavaScript

Advertisement

Answer

  1. In your script you need to move the mv inside the function BUT
  2. Add “please select”
  3. DRY Do not repeat yourself

Here is a better script

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement