public function ajaxxiu(request $request)
{
$id = $request->post('id');
$fd = $request->post('fd');
$new_val = $request->post('new_val');
$res = DB::table('users')->where('id',$id)->update([$fd=>$new_val]);
if ($res){
return 1;
}
}
 <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>展示頁面</title>
<link rel="stylesheet" href="{{asset('css/bootstrap.css')}}">
</head>
<body>
<center><h1>數據展示頁面</h1></center>
<input type="text" name="search" id="search"><input type="button" class="page" value="搜索">
<table class="table table-striped">
{{--@csrf--}}
<tr>
<td><input type="checkbox" id="check"></td>
<td>編號</td>
<td>用戶名</td>
<td>性別</td>
<td>郵箱</td>
<td>創建時間</td>
<td>修改時間</td>
<td>操作</td>
</tr>
<tbody id="tb">
@foreach($data as $key=>$val)
<tr id="{{$val->id}}">
<td><input type="checkbox" name="check" value="{{$val->id}}"></td>
<td>{{$val->id}}</td>
<td fd="username">{{$val->username}}</td>
@if($val->sex == 0 )
<td id="{{$val->id}}" class="se" fd="{{$val->sex}}">男</td>
@elseif($val->sex == 1)
<td id="{{$val->id}}" class="se" fd="{{$val->sex}}">女</td>
@endif
<td fd="email">{{$val->email}}</td>
<td>{{$val->created_at}}</td>
<td>{{$val->updated_at}}</td>
<td><a href="javascript:void (0)" id="{{$val->id}}" class="del">刪除</a>|<a href="update?id={{$val->id }}">編輯</a></td>
</tr>
@endforeach
</tbody>
</table>
<input type="hidden" name="a_page" id="a_page" value="1">
<input type="hidden" name="last_page" id="last_page" value="{{$end}}">
<a href="javascript:void (0)" class="page">首頁</a>
<a href="javascript:void (0)" class="page">上一頁</a>
<a href="javascript:void (0)" class="page">下一頁</a>
<a href="javascript:void (0)" class="page">尾頁</a>
<button class="del_all">批刪</button>
</body>
</html>
<script src="../js/jquery-3.3.1.min.js"></script>
//及時更改
$(document).on("dblclick","td",function () {
var id = $(this).parent().attr('id');
var fd = $(this).attr('fd');
if (fd==undefined){
alert("不能修改");
return;
}
var text = $(this).text();
var that = $(this);
$(this).html('<input type="text" value="'+text+'" class="xiu">');
$(".xiu").blur(function () {
var new_val = $(this).val()
$.ajax({
url:"ajaxxiu",
type:"post",
dataType:"json",
data:{
id:id,
fd:fd,
new_val:new_val,
},
success:function (data) {
if (data==1){
that.html(new_val);
}
}
})
})
})

最新文章

  1. 打开程序总是会提示“Enter password to unlock your login keyring” ,如何成功关掉?
  2. NSLogger 简单用法总结
  3. input-placeholder
  4. STM32启动代码分析 IAR 比较好
  5. svn版本升级遇到的bug
  6. 【转】C++11 标准新特性: 右值引用与转移语义
  7. vb6 判断64位操作系统
  8. Mysql的函数使用方法
  9. iOS - Responder Chain
  10. UVA 1513 Movie collection
  11. Unity Time的使用
  12. linux之SQL语句简明教程---IN
  13. CodeIgniter框架文件结构
  14. php小测试,难点与分享
  15. IIS部署web,字体404的问题
  16. 原来你是这样的Promise
  17. Kotlin 检查空类型
  18. Tom和Jerry在下棋
  19. Linux学习和ROS安装(1)
  20. How to use Junit Listener

热门文章

  1. IE8 CSS样式兼容性清单
  2. java实现大文件上传
  3. 【Python】爬虫汇总
  4. [洛谷P1501] [国家集训队]Tree II(LCT模板)
  5. python3笔记十一:python数据类型-List列表
  6. JDBC连接数据库遇到的“驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。
  7. web安全之如何防止CSRF跨站请求伪造(转载)
  8. [SQL语句的常用统计函数]
  9. golang 开源项目: 配置解析模块--config
  10. Checkbox 多选框