A simple JavaScript project that demonstrates how to populate a dropdown (select) element with data fetched from a JSON API. This project also includes an example of integrating the Select2 library for enhanced dropdown UI.
- Fetches vehicle types from a JSON API endpoint
- Populates a select element dynamically
- Sorts options alphabetically (case-insensitive)
- Supports Select2 for better UX (optional)
- Error handling for failed API requests
- Clone or download this repository.
- Open
index.htmlin your browser. - Make sure your API endpoint is accessible and returns the expected JSON format.
index.html– Main HTML filedropdown.js– Basic dropdown population logicdropdown-select2.js– Dropdown logic with Select2 integration
- Modern browser with JavaScript enabled
- (Optional) Select2 library for enhanced dropdowns
MIT