获取input text的值:(id=“test”)
$(" #test ").val()
这个方法需要为每个form里面的标签都标明name属性
html
@layout("/common/_dialog.html",{plugins:["laydate","sweet-alert","layer"],js:["/assets/modular/system/basic/sendandre/send_edit.js"]}){
<div class="container-fluid">
<form id="sendandreForm">
<div class="row">
<div class="col-6">
<div class="form-group">
<h5>标准名称 <span class="text-danger">*</span></h5>
<div class="controls">
<input name="sendname" type="text" class="form-control sendname" id="sendname">
</div>
</div>
<div class="form-group">
<h5>最小重量 <span class="text-danger">*</span></h5>
<div class="controls">
<input name="minwe" type="text" class="form-control minwe" id="minwe">
</div>
</div>
<div class="form-group">
<h5>最大重量 </h5>
<div class="controls">
<input name="maxwe" type="text" class="form-control maxwe" id="">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="text-xs-right">
<button class="btn btn-info normal-button-width" onclick="ensure()">提交</button>
<button class="btn btn-inverse normal-button-width m-l-10" onclick="closehe()">取消</button>
</div>
</div>
</div>
</form>
</div>
@}
js
ensure = function () {
// console.log("daodao");
var data = {};
$("body").find("#sendandreForm").serializeArray().forEach(function (item) { //获取弹出层写下的数据,input,下拉框啊,之类的表单元素(即changefileform下的所有数据)
data[item.name] = item.value; //根据表单元素的name属性来获取数据
});
console.log(data);
// var result = validateForm();
// if (result === true) {
// DeptEditInfoDlg.addSubmit();
// } else {
// Feng.alert(result);
// }
};