1. 程式人生 > >layer彈窗內新增文字框

layer彈窗內新增文字框

var awards = ""; function confirmUpdateAward(i) { layer.open({ type: 1, closeBtn: false, shift: 7, shadeClose: true, content: "<div style='width:350px;'><div style='width:320px;margin-left: 3%;' class='form-group has-feedback'><p>請輸入獎項名稱</p><input id='awardName' class='form-control' type='text' name='awardName' value='"
+awards[i].awName+"'/></div>" + "<div style='width:320px;margin-left: 3%;' class='form-group has-feedback'><p>請輸入獎項描述</p><input id='awardDescription' class='form-control' type='text' name='awardDescription' value='"+awards[i].awDescription+"'/></div>"+ "<div style='width:320px;margin-left: 3%;' class='form-group has-feedback'><p>請輸入獲獎人數</p><input id='awardUserCount' class='form-control' type='number' name='awardUserCount' value='"
+awards[i].awUserCount+"'/></div>"+ "<div style='width:320px;margin-left: 3%;' class='form-group has-feedback'><p>請輸入獎項類別</p><input id='awardKind' class='form-control' type='text' name='awardKind' value='"+awards[i].awKind+"'/>" + "<button style='margin-top:5%;' type='button' class='btn btn-block btn-success btn-lg' onclick='updateAward("
+awards[i].id+")'>提交</button></div>" }); } function updateAward(awardId){ var awardUserCount = $("#awardUserCount").val(); if(awardUserCount*1>8888 || awardUserCount*1<1){ layer.msg('人數必須是1到8888', { time: 500, //0.5s後自動關閉 // btn: ['明白了', '知道了'] }); }else{ var awardName = $("#awardName").val(); var awardDescription = $("#awardDescription").val(); var awardKind = $("#awardKind").val(); $.ajax({ type: "post", url : getContextPath() + "/award/updateAward", dataType:'json', data: { "awardId":awardId, "awardName":awardName, "awardDescription":awardDescription, "awardUserCount":awardUserCount, "awardKind":awardKind }, success: function(data){ var updateSuccess = data.data; if(updateSuccess){ layer.msg('修改成功', { time: 500, //0.5s後自動關閉 // btn: ['明白了', '知道了'] }); refreshPage(); }else{ layer.msg('修改失敗', { time: 500, //20s後自動關閉 // btn: ['明白了', '知道了'] }); } } }); layer.closeAll(); } }