script.js 2.24 KB
        $(document).ready(function() {

            $(".bookButton").click(function(){
                  pilot=$('#pilot').html();
                  flightID = $(this).attr("id")
                  $.ajax({
                   type: "POST",
                   url: "bookingHandler.php",
                data: "pilot="+pilot+"&action=1&flight="+$(this).attr("id"),
                   success: function(html){   
                   console.log(html)
                if(html=='1')    {
                //$("#add_err").html("right username or password");
                $("#"+flightID).attr("class", "btn");
                $("#"+flightID).attr("disabled", "disabled");
                $("#"+flightID).html("Booking Added");
                }
                else if(html=='2')
                {
                  $("#"+flightID).attr("class", "btn btn-danger");
                  $("#"+flightID).attr("disabled", "disabled");
                  $("#"+flightID).html("Already Booked");
                }
                else    {
                $("#wrongPasswordMessage").css('display', 'inline-block', 'important');
                $("#loadingMessage").css('display', 'none', 'important');
                }
                   }
                  });
                return false;
                });

        $(".removeBooking").bind('dblclick', function(){
        var id = this.id;

        $.ajax({
                   type: "POST",
                   url: "bookingHandler.php",
                data: "id="+id+"&action=2&pilot="+$("#pilot").html(),
                   success: function(html){   
                   console.log(html)
                if(html=='1')    {
                //$("#add_err").html("right username or password");
                  $('#' + id + 'Block').remove();
                }
                
                   }
                  });
        
    });
        $('.vaSelect').on('change', function() {
          var values = this.value.split(".");
            $.ajax({
                   type: "POST",
                   url: "updateVirtualAirline.php",
                data: "va="+values[0]+"&flights="+values[1],
                   success: function(html){   
                   console.log(html)
                   }
                  });
        });
        });