serializeobject(); 可以将表单中的文本框 下拉框 根据name 属性 序列化成字符串,必须在js中写这个方法
$.fn.serializeObject = function() {
var o = {"unique_id":new Date().getTime(),"state":false};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
<form class="form-horizontal m-t" id="design_task_form" οnsubmit="return false">
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">制作项目:</label>
<div class="col-sm-6">
<select style="width:245px;" class="chosen-select" data-id="task_item" id="task_item" name="task_item"></select>
<input type="hidden" id="f_task_item" value="${designTask.task_item}">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">制作类别:</label>
<div class="col-sm-6">
<select style="width:245px;" class="chosen-select" data-id="task_classify" id="task_classify" name="task_classify"></select>
<input type="hidden" id="f_task_classify" value="${designTask.task_classify}">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">色别:</label>
<div class="col-sm-6">
<%-- <input id="color" name="" class="form-control required" value="${designTask.color}"> --%>
<select style="width:245px;" class="chosen-select" data-id="color" id="color" name="color"></select>
<input type="hidden" id="f_color" name="f_color" value="${designTask.color}">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">数量:</label>
<div class="col-sm-6">
<input id="quantity" style="width:245px;" name="quantity" class="form-control required" value="${designTask.quantity}">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">单位:</label>
<div class="col-sm-6">
<select style="width:245px;" class="chosen-select" data-id="unit" id="unit" name="unit" value="${designTask.unit}"></select>
<input type="hidden" id="f_unit" value="${designTask.unit}">
</div>
</div>
<%-- <div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">设计人:</label>
<div class="col-sm-6">
<select style="width:245px;" class="chosen-select" data-id="server" id="designer" name="designer">
<c:forEach items="${userList}" var="user" varStatus="status">
<option value="${user.user_id}" id="user${user.user_id}">${user.true_name}</option>
</c:forEach>
</select>
<input type="hidden" id="f_designer" value="${designTask.designer}">
<input type="hidden" id="designer_name" name="designer_name">
</div>
</div> --%>
<input type="hidden" id="designer" name="designer" value="${designTask.designer}">
<input type="hidden" id="designer_name" name="designer_name" value="${designTask.designer_name}">
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-3 control-label" style="margin-left: 15%;">完成时间:</label>
<div class="col-sm-6">
<input placeholder="完成时间" style="width:245px;" class="form-control layer-date required" id="finish_date" name="finish_date" value="<fmt:formatDate value="${designTask.finish_date}" pattern="yyyy-MM-dd HH:mm:ss"/>">
</div>
</div>
</form>