简体   繁体   English

Select 值和文本不显示 select 与一个选项

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

I am using this code to set a select in a form.我正在使用此代码在表单中设置 select。

    <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.我检查时的 html 部分似乎具有正确的值并将文本放在那里。

But on screen the select box is empty and does not show the text.但是在屏幕上 select 框是空的并且不显示文本。

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. th:text覆盖 html 标签内的任何内容。 You shouldn't have th:text or th:value on a <select /> tag. <select />标签上不应有th:textth:value

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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