欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

layui Ajax请求给下拉框赋值的实例

程序员文章站 2022-06-24 16:21:59
如下所示: 排课设置</ti...</div> <div class="content"> <p><span style="background-color: #ccffcc"><strong>如下所示:</strong></span></p> <div class="jb51code"> <pre class="brush:js;"> <!doctype html> <html> <head> <title>排课设置</title> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="renderer" content="webkit"> <link rel="stylesheet" href="/vendor/layui/css/layui.css" rel="external nofollow" media="all"> </head> <body> <div class="layui-form" lay-filter="boardfilter"> <hr> <div class="layui-form-pane layui-tab-content" style="margin: -10px auto;"> <div class="layui-inline"> <label class="layui-form-label" style="width: 100px;">查询内容</label> <div class="layui-input-inline" style="width: 250px;"> <input class="layui-input" name="schname" placeholder="请输入学校名称" id="schname" autocomplete="off"> </div> </div> <div class="layui-inline"> <label class="layui-form-label" style="width: 100px;">学期</label> <div class="layui-input-inline" style="width: 200px;"> <select name="termid" id="termid"> </select> </div> </div> <div class="layui-inline"> <label class="layui-form-label" style="width: 100px;">列表状态</label> <div class="layui-input-inline" style="width: 150px;"> <select name="msgtype" id="msgtype"> <option value="">全部状态</option> <option value="1">申请中</option> <option value="2">确认申请</option> <option value="3">已经发布</option> <option value="0">已撤销</option> </select> </div> </div> <div class="layui-inline toolbarbtn"> <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" lay-filter="getsearch" id="getsearch" name="getsearch"><i class="layui-icon">&#xe615;</i> 查询</button> </div> </div> </div> <table class="layui-table" id="infotable" lay-filter="filtertable"></table> <script type="text/javascript" src="/vendor/jquery/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="/vendor/layui/layui.js"></script> <script type="text/html" id="action"> <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">查看</a> {{# if(d.status===2){ }} <a class="layui-btn layui-btn-xs" lay-event="send">推送</a> {{# } }} {{# if(d.status===3){ }} <a href='{{d.url}}' class='layui-btn layui-btn-xs'>下载排课表</a> {{# } }} </script> <script type="text/html" id="coursearrangeflag"> {{# if(d.coursearrangeflag===0){ }} <h>行政班排课</h> {{# } else { }} <h>走班排课</h> {{# } }} </script> <script type="text/html" id="status"> {{# if(d.status===0){ }} <h>撤消申请</h> {{# } else if(d.status===1){ }} <h>申请中</h> {{# } else if(d.status===2){ }} <h>排课中</h> {{# } else if(d.status===3){ }} <h>已经推送</h> {{# } else if(d.status===4){ }} <h>已发布课程表</h> {{# } }} </script> <script> layui.use(['table','layer'], function() { var table = layui.table ,form = layui.form; var $ = layui.jquery, layer = layui.layer; var tableins = table.render({ elem: '#infotable' ,url: '/web/coursearrange/list' ,id: 'idtable' ,page: true ,limits: [10,20,50,100] ,limit: 10 //默认采用10 ,cols: [[ //标题栏 {checkbox: true, fixed: true} ,{field: 'coursearrangeid', title: '序号', fixed: true} ,{field: 'schname', title: '学校名称'} ,{field: 'coursearrangeflag', title: '排课类型', templet: '#coursearrangeflag'} ,{field: 'termname', title: '学期'} ,{field: 'recordtime', title: '申请时间'} ,{field: 'status', title: '状态', templet: '#status'} ,{field: 'action', title: '操作', templet: '#action'} ]] }); //监听管理操作 form.on('switch(schcontrolinput)', function(obj){ var normalvalue if(obj.elem.checked){ normalvalue = '0'; }else{ normalvalue = '1'; } $.ajax({ url:'/school/editisnormalschool', type:"post", datatype:"json", data:{"schid":this.value, "statusvalue":normalvalue}, success:function(res){ location.reload(); }, }); }); // 监听table工具条 table.on('tool(filtertable)', function(obj) { var data = obj.data; if (obj.event === 'view') { location.href="coursearrangeview.html?id=" rel="external nofollow" +data.coursearrangeid+"&schid="+data.schid+"&areaid="+data.areaid; }else if (obj.event === 'send') { layer.open({ type: 2, title: '导入并推送', maxmin: true, shadeclose: false, //点击遮罩关闭层 area : ['700px' , '600px'], content: '/page/business/course/coursearrangeupload.html?schid='+data.schid+'&areaid='+data.areaid+'&termid='+data.termid+'&coursearrangeflag='+data.coursearrangeflag+'&phone='+data.phone ,btn: '关闭' ,btnalign: 'c' //按钮居中 ,shade: 0 //不显示遮罩 ,yes: function(){ layer.closeall(); } ,end: function () { location.reload(); } }); } }); form.on('submit(getsearch)', function(data){ table.reload('idtable', { where: data.field }); }); $(document).ready(function () { $("select[name=termnm]").empty(); $.ajax({ async: false, type: "post", url: "/web/coursearrange/termlist", datatype: "json", data: {}, success: function (res) { var opt = "<option value='' selected = \'selected\'>全部</option>"; $("select[name=termid]").append(opt); for(var i=0; i<res.data.length; i++){ var option="<option value=\""+res.data[i].termid+"\""; option += ">"+res.data[i].termname+"</option>"; //动态添加数据 $("select[name=termid]").append(option); } layui.form.render('select','boardfilter'); } }); }); }); </script> </body> </html></pre> </div> <p>以上这篇layui ajax请求给下拉框赋值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。</p> </div> <div class="tags"> 相关标签: <a href="/t/layui/" target="_blank"> layui </a> <a href="/t/Ajax/" target="_blank"> Ajax </a> <a href="/t/%E4%B8%8B%E6%8B%89%E6%A1%86/" target="_blank"> 下拉框 </a> <a href="/t/%E8%B5%8B%E5%80%BC/" target="_blank"> 赋值 </a> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/1517813.html"> Python全栈之学习JS(3) </a> </p> <p> 下一篇: <a href="/article/1517815.html"> asp 一些支付接口 </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/1517814.html" target="_blank" title="layui Ajax请求给下拉框赋值的实例"> <h2> layui Ajax请求给下拉框赋值的实例 </h2> </a> </li> <li> <a href="/article/126636.html" target="_blank" title="ajax请求成功后无法在success方法里给外部变量赋值的问题"> <h2> ajax请求成功后无法在success方法里给外部变量赋值的问题 </h2> </a> </li> <li> <a href="/article/55423.html" target="_blank" title="layui Ajax请求给下拉框赋值的实例"> <h2> layui Ajax请求给下拉框赋值的实例 </h2> </a> </li> <li> <a href="/article/13181.html" target="_blank" title="ajax请求获取的数据赋值给全局变量"> <h2> ajax请求获取的数据赋值给全局变量 </h2> </a> </li> <li> <a href="/article/1110.html" target="_blank" title="关于ajax请求数据,并将数据赋值给全局变量的一些解决方法"> <h2> 关于ajax请求数据,并将数据赋值给全局变量的一些解决方法 </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>