Skip to content
Advertisement

Populate an HTML DropDown List with data from mysql database without PHP

I’m currently building a rails app where im trying to fetch data from different tables from my sql database and I need to put that fetched data (id, first_name, last_name) into an HTML Drop-down where the user is going to select between all possible choices, for exemple:

DROPDOWN Clients:

default: –SELECT–

1 Thomas Carrier

2 Michel Carrier

3 Yvon Dupuis

So if we take the first choice, 1 is the id of the first employee, and his first name (Thomas) and last name (Carrier)

I keep finding stuff about php but I cannot use php!

Thanks for the help

Advertisement

Answer

The easy answer

plain html

or with ruby (https://guides.rubyonrails.org/layouts_and_rendering.html)

Also refer to Yaniv Iny’s answer to for a better more correct way

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