Adding options to a datalist.
We will use one array to store months of a year and then add them as option to the datalist. We will loop through all the elements of the array and prepare the format to store the options in a string variable by using all elements.
Then we will assign this string variable to the datalist by using innnerHTML property.
Each element of our array will be added as option values of the datalist.
The output is here .
Full code is here
Number of options available in a Datalist
Output will be 12
Displaying particular option value.
Output will be June ( Note : options.value is January )
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.