使用Jquery获取thymeleaf中checkbox的值
生活随笔
收集整理的這篇文章主要介紹了
使用Jquery获取thymeleaf中checkbox的值
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
場景
使用thymeleaf模板,需要在列表展示中添加多選框,實現(xiàn)勾選后能獲取到勾選的數(shù)據(jù)的屬性。
?
實現(xiàn)
thymeleaf頁面代碼
?<button id="printBtn"? class="btn btn-info? mb_1em" type="button" onclick="return printDetails()"><i class="fa fa-paste"></i> 打印</button><table id="wmsInOrderDetail_table_id"? class="table? table-bordered hover" style="width:100%"><thead><tr><th>序號</th><th>托盤編號</th><th>物料編號</th><th>物料名稱</th><th>數(shù)量</th><th>供應(yīng)商批次</th><th>生產(chǎn)日期</th><th>狀態(tài)</th></tr></thead><tbody ><tr th:each="orderlist:${wmsReceiveOrderDetailsVOList}"? ><td><input type="checkbox"class="ads_Checkbox"th:text="${orderlist.id}"th:value="${orderlist.id}" name="checkedid"/></td><td th:text="${orderlist.salverCode}"></td><td th:text="${orderlist.materielId}"></td><td th:text="${orderlist.materielName}"></td><td th:text="${orderlist.num}"></td><td th:text="${orderlist.supplierBatch}"></td><td th:text="${#dates.format(orderlist.productDate, 'yyyy-MM-dd HH:mm:ss')}"></td><td th:text="${orderlist.statusName}"></td></tr></tbody></table>選中數(shù)據(jù)后,點擊打印按鈕,來到j(luò)s中的方法。
function printDetails(){debuggervar checkID = [];//定義一個空數(shù)組$("input[name='checkedid']:checked").each(function(i){//把所有被選中的復(fù)選框的值存入數(shù)組checkID[i] =$(this).val();console.log(checkID);});}?
總結(jié)
以上是生活随笔為你收集整理的使用Jquery获取thymeleaf中checkbox的值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: application/x-www-fo
- 下一篇: Jquery中将数组转换成Json