I have a jsp page. if a user enters a certain text a ajax request is sent and and List is retrieved.Bow i want to built a drop down list from the List object and set the default value to the first element of the List Object. How I can do this.
Share
I don’t have any AJAX knowledge so I cant help on that end. So my way of solving this would be doing the most I can in java/jsp’s and then using javascript/AJAX to fetch the select from an auxiliary jsp like this:
Edit:
Actually would be cleaner to build the menu first just with
<c:forEach>using an auxiliary var to numerate the options (in the id field), then use javacript to turn on the selected attribute to the first one. Like this:And you can use something like this to select the first element: