<script type="text/javascript">
$(document).ready(function(e) {
$("#department").on('submit' ,(function(e) {
e .preventDefault();
$('#loadings').show();
$ .ajax({
url : "control.php" , //Url to which the request issend
type : "POST" , //Type of request to be send,called as method
data : new FormData(this), //Data sent to server, a set of key/value pairs(i.e.form fields and values)
contentType : false, //The content type used when sending data to the server.
cache : false , //To unable request pages to be cached
processData : false, //To send DOMDocument or non processed data file it is set to false
beforeSend : function(){
            $('#loadings').show();
        },
success: function(data) //A function to be called if request succeeds
{
$('#loadings').hide();
document.getElementById('inputHere').innerHTML = data;
$('#myModal').modal('show');
document.getElementById('dname').value = "";
document.getElementById('hod').value = "";
}
});
}));
$("#loadd").html('<select class="form-control" name="coordinator" required=""><option selected>.. Select a coordinator</option></select>');
$("#dept").change(function(){
var did = $("#dept").val();
var dataString = "id="+did+"&action=changecor";
 $.ajax({
        type: "POST",
        url: "control.php",
        cache : false,
        data : dataString,
        beforeSend : function(){
           
        },
        success : function(response){
        $("#loadd").html(response);
        }
    });
});
});
</script>





<!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
                <h3><a href="main.php">Dashboard</a>/<a href=" ">Prepare A Class</a></h3>
              </div>
            </div>

            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h3>Prepare A Class</h3>
                    <div class="clearfix"></div>
                  </div>

                <div class="x_content">
                    <form id="department" action ="" method ="post">
                            <div class="row">
                            <div class="col-md-4">
                            <div class="form-group">
                                <label for="plevel" >Level</label>
                                <select class="form-control" name="plevel" id="plevel">
                                    <option value="">Class</option>
                                    <option value="100">100</option>
                                    <option value="200">200</option>
                                    <option value="300">300</option>
                                    <option value="400">400</option>
                                </select>
                            </div>
                            <input type="hidden" name="pdept" value="<?php echo "$id2s" ?>">
                            </div>
                            <div class="col-md-4">
                            <div class="form-group">
                                <label for="psemester" >Semester</label>
                                <select class="form-control" name="psemester" id="psemester">
                                    <option value="">Semester</option>
                                    <option value="1">First</option>
                                    <option value="2">Second</option>
                                </select>
                            </div>
                            </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="pcourse" >Course</label>
                                        <select class="form-control" name="pcourse" id="pcourse" required="">
                                            <option selected>.. Select a course</option>
                                            <?php
                                            $query = $conn->query("SELECT * FROM course order by 'id' DESC");
                                            $fetch = $query->fetchAll(PDO::FETCH_OBJ);
                                            $count = $query->rowCount();
                                            if ($count > 0) {
                                            foreach ($fetch as $key) {
                                            $did = $key->id;
                                            $name = $key->name;
                                            $code = $key->code;
                                            ?>
                                            <option value="<?php echo "$did"; ?>"><?php echo "$name ($code)"; ?></option>
                                            <?php
                                            }
                                            }
                                            ?>

                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="plect" >Lecturer in charge</label>
                                        <select class="form-control" name="plect" id="plect" required="">
                                            <option selected>.. Lecturer</option>
                                            <?php
                                            $query = $conn->query("SELECT * FROM lecturers order by 'id' DESC");
                                            $fetch = $query->fetchAll(PDO::FETCH_OBJ);
                                            $count = $query->rowCount();
                                            if ($count > 0) {
                                            foreach ($fetch as $key) {
                                            $did = $key->id;
                                            $sname = $key->sname;
                                            $oname = $key->oname;
                                            ?>
                                            <option value="<?php echo "$did"; ?>"><?php echo "$sname $oname"; ?></option>
                                            <?php
                                            }
                                            }
                                            ?>

                                        </select>
                                    </div>
                                </div>
                            </div>
                            <button class="btn btn-success submit" type="submit" name="pclass">Submit</button>
                            <span id="loadings" style="display:none;"><img src="../img/loading.gif"></span>

                            </form>
                            </div>
     
                    
                  </div>
                </div>
              </div>
            </div>
          </div>
        <!-- /page content -->


<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-body text-center">
        <div id="inputHere">

        </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Ok</button>
        </div>
      </div>
    </div>
  </div>
</div>