简体   繁体   中英

Select value and text does not show for select with one option

I am using this code to set a select in a form.

    <td>
       <select class="orderNo" th:name="OrderNo" th:value="${order.subOrderNo}"  th:text="${order.subOrderName}">
           <option class="coNameOption" th:value="${order.subOrderNo}"  th:text="${order.subOrderName}" selected></option>
        </select>
    </td>

the html part when i inspect seems to have the proper value and to place the text there.

But on screen the select box is empty and does not show the text.

I also tried to place the text in option in span but it also does not work

th:text overwrites anything inside the html tags. You shouldn't have th:text or th:value on a <select /> tag.

<td>
  <select class="orderNo" name="OrderNo" >
    <option class="coNameOption" th:value="${order.subOrderNo}"  th:text="${order.subOrderName}" selected="selected" />
  </select>
</td>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM