$(document).ready(function () {
    $("body").on('keyup change', '#tsearch', searchschl);
    $("body").on('click', '#acheck', allcheck);
    $("body").on('click', '#mailproceed', SchlModal);

    $("#schlmodal").on('shown.bs.modal', function () {
        $(".tsearch").val("");
        $(".tsearch").focus();
    });

    function allcheck() {
        $(".mcheck").prop('checked', $(this).prop('checked'));
    }

    function searchschl() {
        var tsearch = $("#tsearch").val();

        if (tsearch != "") {
            $.post('getmail_mult.php', {search: tsearch}, function (data) {
                $(".myTable").html(data);
            });
        }
    }

    function SchlModal() {
        var exam = $(".exam").val(),
                center = $(".center").val(),
                session = $(".session").val(),
                section = $(".section").val(),
                medium = $(".medium").val(),
                search = $(".tsearch").val();

        $("#mailmodal").modal('show');
        $(".iloader").show();
        $.post('getmail_mult.php', {center: center, exam: exam, section: section, session: session, medium: medium, search: search}, function (data) {
            $(".myTable").html(data);
            $(".iloader").hide();
        });
    }
});