Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to set a default value for a dropdownlist in html with thymeleaf spring

    <label for="drink">Drink</label>
    <select id="drink" name="drink">
        <option th:each="drink : ${drinks}" th:text="${drink.name}"                //drinks are an array of ENUMs here, drink.name are the lowercase equivalent
                th:value="${drink}" th:selected=${drink==customer.drink}></option> //the customer's last drink will be the default
    </select>
 
PREVIOUS NEXT
Tagged: #set #default #dropdownlist #html #thymeleaf #spring
ADD COMMENT
Topic
Name
3+3 =