모든 선택을 수행하는 Thinkphp 방법: 1. 프런트 엔드 샘플 파일을 만들고 html 버튼을 설정합니다. 2. js 코드 "layui.use('form', function () {...}"를 사용하여 선택합니다. 모든 데이터 ;3. thinkphp 파일을 열고 "public function deleteAll(){...}" 메소드를 사용하여 모두 삭제하세요.
이 튜토리얼의 운영 환경: Windows 7 시스템, ThinkPHP 버전 5 , Dell G3 컴퓨터
thinkphp에서 모든 선택을 구현하는 방법은 무엇입니까?
thinphp5+html 모두 선택하고 선택을 반전하고 다중 선택 후 삭제
최근에 버튼의 다중 선택을 연구했는데 보세요, 코드에 대해서는 별로 할 말이 없습니다
html 버튼
<input style="float: right;margin-left: 10px" type="checkbox" lay-skin="primary" id="c_all" lay-filter="c_all" title="全部"> <input style="float: right;margin-left: 10px" type="checkbox" lay-skin="primary" id="f_all" lay-filter="f_all" title="反选"> <input style="float:right;margin-top: 3.5px;margin-left:10px" type="button" id="btndelete" class="layui-btn layui-btn-sm" value="删除">
js
<!-- 多选删除 --> <script type="text/javascript"> $('#btndelete').click(function(){ var a = document.getElementsByName("cityId"); var b=[]; for(i in a){ if(a[i].checked) b.push(a[i].value); } if(b==""){alert('请选择数据删除')}else{ layer.confirm('确定要删除?', function(index) { window.location.href='/admin/commodity/deleteAll?b='+b; })} }) </script> <!-- 全选框 --> <script type="text/javascript"> layui.use('form', function () { var form = layui.form; //全选 form.on('checkbox(c_all)', function (data) { var a = data.elem.checked; if (a == true) { $(".cityId").prop("checked", true); form.render('checkbox'); } else { $(".cityId").prop("checked", false); form.render('checkbox'); } }); //反选 form.on('checkbox(f_all)', function (data) { var item = $(".cityId"); item.each(function () { if ($(this).prop("checked")) { $(this).prop("checked", false); } else { $(this).prop("checked", true); } }) form.render('checkbox'); }); //有一个未选中全选取消选中 form.on('checkbox(c_one)', function (data) { var item = $(".cityId"); for (var i = 0; i < item.length; i++) { if (item[i].checked == false) { $("#c_all").prop("checked", false); form.render('checkbox'); break; } } //如果都勾选了 勾上全选 var all=item.length; for (var i = 0; i < item.length; i++) { if (item[i].checked == true) { all--; } } if(all==0){ $("#c_all").prop("checked", true); form.render('checkbox');} }); }); </script>
삭제할 메소드로 이동하는 것입니다
// 删除全部 public function deleteAll(){ $b=input('b'); // Db::name('excel')->where('id','in',$b)->delete(); if(false == Db::name('commodity')->where('id','in',$b)->delete()) { return $this->error('删除失败,请选择要删除的数据'); } else { return $this->success('删除成功','admin/commodity/index'); } }
권장 학습: "thinkPHP 비디오 튜토리얼"
위 내용은 thinkphp에서 모든 선택을 달성하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)
