Good day!
I have a problem with a select box in html. I am in the EDIT part of my simple CRUD project and before users can edit, the selected data will be shown first and I will extract it to the database through the servlet.
Now I want the data I receive to be selected in the SELECTED select box (default). ${product.category}
<select size="1" name="category"> <option value ="1">Dogs</option> <option value ="2">Cats</option> <option value ="5">Others</option> </select>
I tried to insert it like this, but it does not work.
<select size="1" name="category" selected=${product.category}> <option value ="1">Dogs</option> <option value ="2">Cats</option> <option value ="5">Others</option> </select>
I want to do something like this .. If ($ {product.category} == 1), selected = option 1 ...
I saw something like this on one of the forums, but in PHP format. How can I do this using JSP?
Many thanks.
html select jsp
newbie
source share