Tip: Consistent index in HTML drop-down list and JS array
Problem: Populate a drop-down list with array values. After a user selects a value, get the array index of that value. Solution: Populate the value attributes with the array indexes. These are hidden from the user. Here’s a working example: The page is nothing but a drop-down list: When a selection is made, a text is printed: P.S. In this example the first option is Select Car. It is not […]