在浏览器上显示时,无法在此jquery代码行中编辑表单

时间:2018-06-10 07:07:40

标签: javascript jquery html

请注意,这不是我的代码,所以我不太明白。所以,这是用于触发divedit成员的html,如下所示

<div class="right-sidebar divedit-member">
    <div class="container-fluid">
        <br>
        <br>
        <div class="member-form"></div>
    </div>
</div>

然后这是我用来编辑编辑MEMBER的形式的脚本,只是想将输入标签name = s_year的值更改为其他如(1st,2nd,3rd)但是却无法设法这样做。当我编辑选项标签时,它仍然显示这个表格,我不想要..

$('.add_student').click(function()
{   
    $('.divedit-member').toggle(effect, options, duration);

    var form = '<form class="frm_add_student">\
                    <br/><br/><h4 class=""></h4>\
                    <hr>\
                    <div class="form-group">\
                        <label>School ID Number</label>\
                        <input type="number" name="sid_number" class="form-control" required autocomplete="off">\
                    </div>\
                    <div class="form-group">\
                        <label>First Name</label>\
                        <input type="text" name="s_fname" class="form-control text-capitalize" required autocomplete="off">\
                    </div>\
                    <div class="form-group">\
                        <label>Last Name</label>\
                        <input type="text" name="s_lname" class="form-control text-capitalize" required autocomplete="off">\
                    </div>\
                    <div class="form-group">\
                        <label>Gender</label>\
                        <select name="s_gender" class="form-control" required>\
                            <option disabled selected>Your gender</option>\
                            <option>Male</option>\
                            <option>Female</option>\
                        </select>\
                    </div>\
                    <div class="form-group">\
                        <label>Contact Number</label>\
                        <input type="tel" name="s_contact" class="form-control" required autocomplete="off">\
                    </div>\
                    <div class="form-group">\
                        <label>Department</label>\
                        <select name="s_department" class="form-control" required>\
                            <option disabled selected>Select department</option>\
                            <option>FSKM</option>\
                        </select>\
                    </div>\
                    <div class="form-group hide">\
                        <label>Major</label>\
                        <input type="text" name="s_major" class="form-control" autocomplete="off">\
                    </div>\
                    <div class="form-group">\
                        <div class="row">\
                            <div class="col-md-6">\
                                <label>Year</label>\
                                <select name="s_year" class="form-control" required>\
                                    <option selected disabled>Select year</option>\
                                    <option>1</option>\
                                    <option>2</option>\
                                    <option>3</option>\
                                    <option>4</option>\
                                    <option>5</option>\
                                </select>\
                            </div>\
                            <div class="col-md-6">\
                                <label>Section</label>\
                                <input type="text" name="s_section" class="form-control text-capitalize" required autocomplete="off">\
                            </div>\
                        </div>\
                    </div>\
                    <div class="form-group">\
                        <button class="btn btn-primary btn_faculty" type="submit"><i class="fa fa-plus"></i> Add</button>\
                        <button class="btn btn-danger btn_frm_add" type="reset"><i class="fa fa-remove"></i> Cancel</button>\
                    </div>\
                </form>';

        $('.member-form').html(form);
        $('.btn_frm_add').click(function(e){
            $('.divedit-member').toggle(effect, options, duration);
        });

        $('.frm_add_student').submit(function(e){
            e.preventDefault();
            var frmdata = $(this).serialize()+'&key=add_newstudent';

            $.ajax({
                type: "POST",
                url: "../class/add/add",
                data: frmdata
            })
            .done(function(data){
                // console.log(data);
                if(data == 1){
                    toastr.success('Student successfully added.');
                    $('.btn_frm_add').click();
                    table_member.ajax.reload(null,false);

                }else if(data == 2){
                    toastr.warning('Student already exist.');
                }else{
                    toastr.error('Failed to add.');
                }
            });

        });

});

如果我错了,请帮助我。

0 个答案:

没有答案