在修改的时候和在PHP里面修改的一样,都是需要在列表页传个id过来才可以实现修改的,如下所示:
然后在后端接收到他传过来id的同时去读取该id的所有信息:
然后就开始写post处理数据方面的问题了,如下所示:
<% include header.html %> <div class="wrapper row-offcanvas row-offcanvas-left"> <!-- Left side column. contains the logo and sidebar --> <% include left.html %> <!-- Right side column. Contains the navbar and content of the page --> <aside class="right-side"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> 分类编辑 <small>分类</small> </h1> <ol class="breadcrumb"> <li><a href="index.html"><i class="fa fa-dashboard"></i> 管理中心</a></li> <li class="category_list.html"><a href="index.html">分类</a></li> <li class="active">分类编辑</li> </ol> </section> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-md-12"> <div class="box"> <form action="/admin/category/edit" method="post"> <div class="box-header"> <h3 class="box-title"></h3> <a href="/Admin/Category/" class="btn btn-default pull-right">分类列表</a> </div><!-- /.box-header --> <div class="box-body"> <div class="form-group"> <label for="inputTitle">分类标题</label> <input type="title" placeholder="标题" id="inputTitle" name="title" value="<%= data.title %>" class="form-control"> </div> <div class="form-group"> <label for="inputOrderNumber">排序</label> <input type="title" placeholder="排序" id="inputOrderNumber" name="sort" value="<%= data.sort %>" class="form-control"> </div> <input type="hidden" name="id" value="<%= data._id %>"> </div><!-- /.box-body --> <div class="box-footer clearfix"> <button class="btn btn-primary" type="submit">提交</button> </div><!-- /.box-footer --> </form> </div><!-- /.box --> </div><!-- /.col --> </div><!-- /.row --> </section><!-- /.content --> <% include footer.html %>
而且修改也是由两部才可以完成,这里其实和PHP也是一样的,首先接收到id,然后对edit页进行遍历该id的数据,然后就是修改了,
时间: 2024-10-08 17:38:21