首页 > 代码库 > layer弹框

layer弹框

function canshuadd(){
    var html=‘<div class="panel panel-default toggle">‘;
      //  html+=‘<label class="col-lg-2 control-label">*名称:</label>‘;
        html+=‘<div class="col-lg-4" style="margin-left:60px;margin-top:40px;">‘;
        html+=‘<input type="hidden" name="style" id="style"  value="http://www.mamicode.com/add">‘;
        html+=‘名称:<input type="text" id="parmaName" name="parmaName" value="" >‘;
        html+=‘</div>‘;
        html+=‘</div>‘;

    layer.open({
        shade: 0.8,
        title: ‘添加参数名称‘,
        type: 1,
        area : [‘400px‘ , ‘200px‘],
        btn: [‘提交‘, ‘取消‘],
        yes: function(index, layero){
            var parma = {};
            parma.parentId=parentId1;
            parma.style=$("#style").val();
            parma.parmaName = $("#parmaName").val();
            console.log(parma.parmaName);console.log(parma.parentId);console.log(parma.style);
            if(parma.parmaName== ""){
                layer.msg("数据不能为空");
                layer.close(index);
                return false;
            }
            $.post(submiturl,parma,function(data){
                if(data == 1){
                    window.location.href=http://www.mamicode.com/window.location.href;"操作成功");
                    layer.close(index);
                }else if(data=http://www.mamicode.com/=3){"数据重复了。")
                }
                else{
                    layer.msg("操作失败");
                }
            });
            layer.close(index);
        },
        close : function(index){
            layer.close(index);
        },




        content: html
    });
    return false;
}
传参数到iframe页面打开页面并进行数据验证
function typemod(pr){
    _followTypeId=$(pr).attr(‘data‘);
    var submiturl=$(pr).attr(‘data1‘);
    var houseediturl=$(pr).attr(‘data2‘);
    layer.open({
        shade: 0.8,
        title: ‘修改参数名称‘,
        type: 2,
        area: [‘600px‘, ‘580px‘],
        btn: [‘提交‘, ‘取消‘],
        yes: function (index, layero) {
            var parma = {};
            parma.followTypeId =_followTypeId;
            parma.style =‘mod‘;
            parma.followText = $.trim(layer.getChildFrame(‘[name="followText"]‘, index).val());
            parma.examineStyle = $.trim(layer.getChildFrame(‘input:radio[name=examineStyle]:checked‘,index).val());
            //parma.style = $.trim(layer.getChildFrame(‘[name="style"]‘, index).val());
            parma.range =$.trim(layer.getChildFrame(‘[name="range"]‘, index).val());
            parma.examineJob =$.trim(layer.getChildFrame(‘[name="examineJob"]‘, index).val());
            console.log(parma.followText);
            console.log(parma.style);
            console.log(parma.examineStyle);
            console.log(parma.range);
            console.log(parma.examineJob);
            if (parma.followText == "") {
                layer.msg("数据不能为空");
                layer.close(index);
                return false;
            }
            $.post(submiturl, parma, function (data) {
                if (data == 1) {
                    window.location.href = window.location.href;
                    layer.msg("操作成功");
                    layer.close(index);
                } else if (data == 3) {
                    layer.msg("数据重复了。")
                }
                else {
                    layer.msg("操作失败");
                }
            });
            layer.close(index);
        },
        close: function (index) {
            layer.close(index);
        },
        content: houseediturl+‘&followTypeId=‘+_followTypeId
    });
    return false;
}


layer弹框