00023-layui表单有checkradioswitch,未选中时值不提交的解决
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了00023-layui表单有checkradioswitch,未选中时值不提交的解决相关的知识,希望对你有一定的参考价值。
表单字段:
<div class="layui-form-item layui-form-item-45" >
<label class="layui-form-label">是否需要外勤</label>
<div class="layui-input-block">
<input type="checkbox" name="isNeedOut" lay-filter="form-switch" lay-skin="switch" lay-text="是|否">
</div>
</div>
<div class="layui-form-item layui-form-item-45" >
<label class="layui-form-label">是否收费</label>
<div class="layui-input-block">
<input type="checkbox" name="isCost" lay-filter="form-switch" lay-skin="switch" lay-text="是|否">
</div>
</div>
<div class="layui-form-item layui-form-item-45" >
<label class="layui-form-label">是否延期</label>
<div class="layui-input-block">
<input type="checkbox" name="isDelay" lay-filter="form-switch" lay-skin="switch" lay-text="是|否">
</div>
</div>
提交:
var dialog = layer.open({
type: 2
,title: ‘添加任务单‘
,content: ‘../task/taskForm.jsp‘
,maxmin: true
,area: layui.setter.area
,btn: [‘确定‘, ‘取消‘]
,btnAlign: ‘c‘
,yes: function(index, layero){
var iframeWindow = window[‘layui-layer-iframe‘+ index]
,submit = layero.find(‘iframe‘).contents().find("#taskForm-submit");
iframeWindow.layui.form.on(‘submit(taskForm-submit)‘, function(data){
var field = data.field;
field.taskSource = 1;//合同事项
field.isUrgent = field.isUrgent?field.isUrgent:false;
field.isNeedOut = field.isNeedOut?field.isNeedOut:false;
field.isCost = field.isCost?field.isCost:false;
field.isDelay = field.isDelay?field.isDelay:false;
var rtn = admin.syncReq(ctx+"/task/task/add",field);
if(rtn && rtn.code==0){
layer.msg(‘操作成功‘);
active.reload();
layer.close(index);
}else{
layer.msg(‘操作失败‘);
}
});
submit.trigger(‘click‘);
}
});
layer.full(dialog)
像这样:
field.isUrgent = field.isUrgent?field.isUrgent:false;
无值是传false 到后台即可。
以上是关于00023-layui表单有checkradioswitch,未选中时值不提交的解决的主要内容,如果未能解决你的问题,请参考以下文章