How to display hashmap values in an HTML dropdown box using Java?
HashMap<Integer,String> hm =new HashMap<Integer,String>();
hm.put(1,"abc");
hm.put(2,"def");
hm.put(3,"ghi");
Using the jEasyUI framework with jQuery.
How to display hashmap values in an HTML dropdown box using Java?
HashMap<Integer,String> hm =new HashMap<Integer,String>();
hm.put(1,"abc");
hm.put(2,"def");
hm.put(3,"ghi");
Using the jEasyUI framework with jQuery.
<%
HashMap<Integer,String> hm =new HashMap<Integer,String>();
hm.put(1,"abc");
hm.put(2,"def");
hm.put(3,"ghi");
for(int i=1;i<hm.size();i++){
%>
<option value="<%= i%>"><%= hm.get(i) %></option>
<% } %>
You can use list returned from hm.values()
Take a for loop and build options like below
"<option value="+hm.getKey()+">"+hm.getValue()+"</option>";
HashMap doc.