<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>企业列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="http://www.17sucai.com/preview/1349775/2019-03-28/layui-master/src/css/layui.css" />
</head>
<body>
<form class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">复选框</label>
<div class="layui-input-block">
<input type="checkbox" name="like" value="1" title="写作">
<input type="checkbox" name="like" value="2" title="阅读" >
<input type="checkbox" name="like" value="3" title="发呆">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
<script src="http://www.17sucai.com/preview/1528155/2019-03-08/sort/layui/layui.js"></script>
<script>
layui.use('form', function(){
var form = layui.form;
form.on('submit(formDemo)', function(data){
//获取checkbox[name='like']的值
var arr = new Array();
$("input:checkbox[name='like']:checked").each(function(i){
arr[i] = $(this).val();
});
data.field.like = arr.join(",");//将数组合并成字符串
$.post("admin.php", {data:data.field}, function (res) {
if (res.code == 1) {
layer.msg(res.msg, {time: 1800, icon: 1}, function () {
location.href = res.url;
});
} else {
layer.msg(res.msg, {time: 1800, icon: 2});
}
}, 'json');
return false;
});
});
</script>
layui 复选
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...