Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simplifying list of "time" options with jsp  RSS feed

 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to "clean up" a cluttered mess of html, scriptlets, and javascript using some jsp tags. The first thing I noticed was a long list of options signifying time of day (spaced 15 minutes apart, starting at 4am and ending at 11:45pm). Is there a way to rewrite this using jsp? The code is as follows:



Any help would be greatly appreciated, thank you!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this sort of thing (statically defined options) I usually define a sorted Map and use it to populate the option elements. The Map key serves as the option value, and the Map value as the display text for the option.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!