由输入id的文本框,转到选择框选择返回给后台id

1.后台给前台一个id对应name的list,可以直接是List(添加修改一样)

 /**
    * 添加跳转页面
    * @return
    */
    @GetMapping("editBefore/{id}")
    public String editBefore(Model model,@PathVariable("id")Long id){
        //这就是原本回显得数据
        model.addAttribute("tutorialCover",tutorialCoverService.getById(id));
        //这是选择框的数据   
        model.addAttribute("tutorialsTypeList",tutorialsTypeService.list());
        return prefix+"edit";
    }

2.前台显示(增加,不需要回显)

注意:粘贴后,name和id一定要该改

  <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>教程分类编号:</label>
                <div class="layui-input-inline">
                    <select name="tutorialsTypeId" id="tutorialsTypeId">
                        <option value="">请选择资源类型:</option>
                        <option th:each="tutorialsType : ${tutorialsTypeList}"
                                th:value="${tutorialsType.id}"
                                th:text="${tutorialsType.tutorialType}"></option>
                    </select>
                </div>
            </div>

2.前台显示(修改,回显th:field="${tutorialsRelation.chapterId}")

注意:

  • 粘贴后,name和id一定要该改
  • th:field"$ {}“对应的是下面的th:value=”${chapter.id}"
<div class="layui-form-item">
                <label class="layui-form-label"><span
                        class="c-red">*</span>章节编号:</label>
                <div class="layui-input-inline">
                    <select name="tutorialsTypeId" id="tutorialsTypeId" th:field="${tutorialsRelation.chapterId}">
                        <option value="">请选择章节:</option>
                        <option th:each="chapter:${chapters}"
                                th:value="${chapter.id}"
                                th:text="${chapter.tutorialsName}"></option>
                    </select>

                </div>
            </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的实现方案: ```html <!DOCTYPE html> <html> <head> <title>学生信息提交表单</title> </head> <body> <h2>学生信息提交表单</h2> <form action="process_form.php" method="POST" enctype="multipart/form-data"> <label for="name">姓名:</label> <input type="text" id="name" name="name" required><br> <label for="password">登录密码:</label> <input type="password" id="password" name="password" required><br> <label for="confirm_password">确认密码:</label> <input type="password" id="confirm_password" name="confirm_password" required><br> <label for="class">班级:</label> <select id="class" name="class"> <option value="1">一班</option> <option value="2">二班</option> <option value="3">三班</option> </select><br> <label for="student_id">学号:</label> <input type="text" id="student_id" name="student_id" required><br> <label for="gender">性别:</label> <input type="radio" id="male" name="gender" value="male" required> <label for="male">男</label> <input type="radio" id="female" name="gender" value="female"> <label for="female">女</label><br> <label for="hobbies">兴趣爱好:</label> <input type="checkbox" id="movie" name="hobbies[]" value="movie"> <label for="movie">电影</label> <input type="checkbox" id="music" name="hobbies[]" value="music"> <label for="music">音乐</label> <input type="checkbox" id="reading" name="hobbies[]" value="reading"> <label for="reading">阅读</label><br> <label for="avatar">头像:</label> <input type="file" id="avatar" name="avatar"><br> <label for="scores">课程成绩:</label> <input type="number" id="scores" name="scores" min="0" max="100" required><br> <label for="remark">备注:</label> <textarea id="remark" name="remark"></textarea><br> <label for="other_info">其他信息:</label> <input type="text" id="other_info" name="other_info"><br> <input type="submit" value="提交"> <input type="reset" value="重置"> </form> </body> </html> ``` 该表单包含了各种不同类型的输入域,例如文本框、密码、下拉列表、单选、复选、文件上传、数字输入和文本域。其中,提交按钮的 type 属性为 "submit",重置按钮的 type 属性为 "reset"。 对于一些必填项,我们使用了 HTML5 中的 required 属性,可以在用户没有填写这些项目时提示用户进行填写。 在 form 标签中,我们设置了 action 属性为 "process_form.php",这表示表单提交后将会把表单数据发送到 process_form.php 这个 PHP 文件中进行处理。 在 PHP 文件中,我们可以使用 $_POST 数组获取到表单提交的数据。例如,$_POST["name"] 就表示提交的姓名。注意,由于我们设置了 enctype 属性为 "multipart/form-data",所以上传的文件需要通过 $_FILES 数组获取。 接下来,我们可以在 PHP 中对表单提交的数据进行处理,例如验证用户输入的合法性、存储数据等操作。最后,我们可以将处理后的数据显示在网页上,让用户确认提交的信息是否正确。 这只是一个简单的实现示例,如果想要更加完善的表单验证和处理逻辑,还需要进行更多的工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值