Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Forms Choosing Options Select Menus

(Forms: Select Menus) What if I have 50 option values to list? Is there a simpler way than listing them one-by-one?

It would be a hassle to make html code for 50 option values. Is there any other way to do the same job?

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

I would say yes and no.

Yes, but you would need a backend language (i.e. PHP), and you would still need to enter the data into an array, dictionary or database. With one of these, you could use a loop to insert the HTML, but it will require knowledge of backend programming.

Regardless of how you do it... all the data would still need to be entered at some point.

:)

If you are referring options with large numbers (ie. nationality list) there will be probably pre-set libraries available for you on the web.

Steve Gallant
Steve Gallant
14,943 Points

Without access to the back-end stuff already mentioned, you could use Excel to easily copy the similar html tags etc for all the different rows and manipulate the text into the code you need. Then just copy the code into your HTML file. This would help minimize the typing, though all the values would still need to be entered.