layui前端+springboot框架--商品绑定多个分类代码

本文展示了如何使用layui前端框架结合SpringBoot后端,实现商品绑定多个分类的功能。通过前端js动态添加选择框,允许至少绑定一个分类,并在切换一级分类时自动更新二级分类选项。在后台,由于设计考虑,商品表仅存储一个二级分类,其余通过关联表进行存储。
摘要由CSDN通过智能技术生成

直接上效果图:
在这里插入图片描述
通过选择框选择自己想要绑定的多个分类!


上干货:
<div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>绑定分类:</label>
            <table class="layui-table text-c" id="classTable" style="width: 80%;">
                <thead>
                <tr class="text-c">
                    <td style="width:130px">一级分类</td>
                    <td style="width:130px">二级分类</td>
                    <td style="width:50px">操作</td>
                </tr>
                </thead>
                <tbody id="tbody2">
                    <!--一级分类-->
                    <tr class="text-c" id="1" style="background: #fff;">
                        <td>
                            <div class="formControls col-xs-10 col-sm-10">
                                <select onchange="selectedGoodsSecondType()" id="firstGoodsTypeId" type="input-text" class="input-text" name="firstGoodsTypeId">
                                    <option th:each="goodsType:${goodsTypeList}" th:if="${goodsType.parentId == 0}" th:value="${goodsType.id}"><span th:text="${goodsType.type}"></span></option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <div class="formControls col-xs-10 col-sm-10">
                                <select id="goodsTypeId" type="input-text" class="input-text" name="secondClass" >
                                    <option  th:each="goodsType:${goodsTypeList}" th:data="${goodsType.parentId }" th:if="${goodsType.parentId != 0}" th:value="${goodsType.id}"><span th:text="${goodsType.type}"></span></option>
                                </select>
                            </div>
                        </td>
                        <td><!--空的操作--></td>
                    </tr>

                </tbody>
            </table>
            <a title="添加分类" href="javascript:;"
               th:onclick="'javascript:addClass()'"
               class="ml-5" style="text-decoration:none;margin-left: 145px;"><i class="Hui-iconfont">&#xe604;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值