<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script> </head> <body> <div class="row"> <div class="form-group"> <label class="col-md-4 col-sm-4 col-xs-4 control-label">周期选择</label> <div class="col-md-7 col-sm-7 col-xs-7"> <label><input name="circle" type="checkbox" value="2" />星期一</label> <label><input name="circle" type="checkbox" value="3" />星期二 </label> <label><input name="circle" type="checkbox" value="4" />星期三 </label> <label><input name="circle" type="checkbox" value="5" />星期四 </label> <label><input name="circle" type="checkbox" value="6" />星期五 </label> <label><input name="circle" type="checkbox" value="7" />星期六 </label> <label><input name="circle" type="checkbox" value="1" />星期日 </label> </div> </div> </div> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="col-md-4 col-sm-4 col-xs-4 control-label">点位名称<em style="color: red;">*</em></label> <div class="col-md-7 col-sm-7 col-xs-7"> <input type="text" class="form-control " id="potName"> </div> </div> </div> </div> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <div class="form-group"> <label class="col-md-3 col-sm-3 col-xs-3 control-label">重要级别</label> <div class="col-md-6 col-sm-6 col-xs-6"> <select id="rank" class="form-control select2" style="width: 170px"> <option>重要</option> <option>一般</option> </select> </div> </div> </div> </div> <div> <button onclick="submit()">submit</button></div> <script type="text/javascript"> function submit() { var params = { potName: $("#potName").val(), rank: $("#rank option:selected").val(), circle: getCircle(), } alert(JSON.stringify(params)); $.ajax({ url: basePath + "/sign", contentType: 'application/json', data: JSON.stringify(params), type: "POST", success: function(data) {} }); } //获取选中的周期 function getCircle() { var str = ""; $("input[name='circle']").each(function() { if($(this).prop("checked") == true) { str += ($(this).val() + ",") } }); return str; } </script> </body> </html>