A good example can be a dropdown list that contains options like Animals, Books, and Movies. Based on the user selection, we will display a list of animals, books, or movies. The first step would be to get the value of the selected option and make a request to the server. The server will then return the data and we will display it to the user.
In the following example, we have a dropdown list with a bunch of options. We will select a random option from the list and display its value on the screen. Please have a look over the code example and the steps given below.
HTML & CSS
We have a few elements in the HTML file and that includes div, select, option, h2, and h3.
The div element with a style attribute is just a wrapper for the rest of the elements.
The select element has 5 options. The first option with text “Select” is default with hidden and disabled attributes.
The inner text for the h2 element is “Result”.