Thymeleaf选中checkbox和radio

⏹选中radio,各个radio按钮的value值不同

 <table>
    <tr>
        <td style="padding-right: 18px">
            <input id='statusJyunnbi' th:checked="*{sneStatus} eq '1'" type="radio" th:field="*{sneStatus}" value="1">
            <label for="unStart" style="margin-bottom:5px;">準備中</label>
        </td>
        <td style="padding-right: 18px">
            <input id='statusCommit' th:checked="*{sneStatus} eq '2'" type="radio" th:field="*{sneStatus}" value="2">
            <label for="inProgress" style="margin-bottom:5px;">提出済</label>
        </td>
        <td style="padding-right: 30px">
            <input id='statusEnd' th:checked="*{sneStatus} eq '3'" type="radio" th:field="*{sneStatus}" value="3">
            <label for="end" style="margin-bottom:5px;">完了</label>
        </td>
    </tr>
</table>

⏹选中CheckBox,各个value的值相同

<table>
    <tr>
        <td style="padding-right: 30px">
            <input id='sneTeiFuyo' th:field="*{sneTeiFuyo}" type="checkbox" value="1">
            <label for="sneTeiFuyo">不要</label>
        </td>
        <td style="padding-right: 30px">
            <input id='sneTeiToitu' th:field="*{sneTeiToitu}" type="checkbox" value="1">
            <label for="sneTeiToitu">統一</label>
        </td>
        <td style="padding-right: 30px">
            <input id='sneTeiDokuji' th:field="*{sneTeiDokuji}" type="checkbox" value="1">
            <label for="sneTeiDokuji">独自</label>
        </td>
        <td>
            <input id='sneTeiItigen' th:field="*{sneTeiItigen}" type="checkbox" value="1">
            <label for="sneTeiItigen">一元</label>
        </td>
    </tr>
</table>

⏹thymeleaf控制checkbox的选中状态回显

<input id="test" type="checkbox" th:attr="checked=(${user.getAutoSell()} == 1 ? true: false)">

⏹thymeleaf控制下拉列表的回显

<div class="form-group">
    <label for="accountType">账户类型</label>
    <select class="form-control" id="accountType" name="accountType">
        <option th:text="${account.getAccountType()}" selected> </option>
        <option value="支付宝" >微信支付</option>
        <option value="支付宝">支付宝</option>
        <option value="银行卡">银行卡</option>
    </select>
</div>
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值