Febin Febin - 1 month ago 13
HTML Question

Datalist does not show values after space (not showing whole string value)

Using servlets, I am trying to get datalist from database. But datalist does not show the whole string value.
Example: "Computer Science" displayed as "Computer" in dayalist options. Values are displayed correctly in the console, Eg:"Computer Science"

out.println("<input list=\"dept12\" id=\"dept1\" > <datalist id=\"dept12\">");
while(itr.hasNext())
{
Long key=(Long) itr.next();
out.println("<option value="+map.get(key)+" id="+key+">");
out.println("</option>");
}
out.println("</datalist>");

Answer

You did an mistake in this line:

out.println("<option  value="+map.get(key)+" id="+key+">");

I think it must be:

out.println("<option  value=\""+map.get(key)+"\" id=\""+key+"\">");
Comments