Press Enter

PROJECT TITLE

    Press Enter

    PROJECT TITLE
    enable disable option value in select based on condition PHP

    enable disable option value in select based on condition PHP

    • 3 Comments
    • 0 Bids
    • MYR0.00 Avg Bid (MYR)
    • Active on June 11, 2019

    Project description:

    After user select location,in the next select option which is select car, will show list of car in selected location..The list of car retrieved direct from database..So i need to display all the car list in that area and need to disable enable the car list according the condition which is if the car id is not available the option value will disabled..and the option value become enable if car id is available..

      <select class=”form-control” name=’car_id’ id=”car_id” required>
             
                <?php
               
                $car = “SELECT *,location_master.location_id , location_master.location_name,
                appcarinfo.loc_id_ext, appcarinfo.location ,appcarinfo.model ,appcarinfo.noplat FROM location_master
               INNER JOIN appcarinfo ON
                appcarinfo.lat = location_master.gmaplat
                AND
                appcarinfo.lon = location_master.gmaplng
                where appcarinfo.model=’”.$fetchres[‘idmodel’].”‘  “;
           
                $qcar = mysqli_query($conn, $car);
                ?>
               <option disabled value=”” selected hidden>Please Select Car</option>
                <?php
                while ($showcar= mysqli_fetch_array($qcar))
                {
                    
        if ($showcar[‘car_id’]==”Available”)
        {     
        ?>
                <option  class=”<?php echo $showcar[‘lon’]; ?>” value=”<?php echo $showcar[‘car_id’]; ?>” enabled> <?php echo $fetchres[‘maker’].’ ‘.$fetchres[‘model_name’].’-‘.$showcar[‘noplat’].’ ‘ .$showcar[‘location_name’]; ?></option>

                 <?php
          }
         else
         ?> <option  class=”<?php echo $showcar[‘lon’]; ?>” value=”<?php echo        $showcar[‘car_id’]; ?>” disabled> <?php echo $fetchres[‘maker’].’      ‘.$fetchres[‘model_name’].’-‘.$showcar[‘noplat’].’ ‘     .$showcar[‘location_name’]; ?></option>
          <?php
                     }
                  ?>
                </select>

    I’m also new to AJAX..how to pass data and retrieve it back to select option

         //check availability car
        function check_availability()
        {
            //id from form
            var reservation1 = document.getElementById(“reservation”);
            var pickup_date = document.getElementById(“pickup_date”).value;
            var return_date = document.getElementById(“return_date”).value;
            var pickup_time = document.getElementById(“pickup_time”).value;
            var return_time = document.getElementById(“return_time”).value;
            var carID= document.getElementById(“carID”).value;
                    $.ajax({
                        type : “POST”,
                        url : “function/check_car_availability.php”,
                        data : {
                            pickup_date : pickup_date,
                            return_date : return_date,
                            pickup_time : pickup_time,
                            return_time : return_time,
                            carID : carID,
                   
                        },
                        dataType : “JSON”,
                        success : function(data) {
                            $(‘#edt_pickup’).val(data.edt_pickup);
                            $(‘#edt_return’).val(data.edt_return);
                            $(‘#msgCheck’).html(data.msgCheck);
                            $(‘#btn_proceed’).html(data.btn_proceed);
                       
                        }
                    });   
        }

    3 Comments

    1. Azilah J

      If you’re still stuck with this problem, feel free reach me at azilahjhr on Telegram. 🙂

    2. mohamad aziman mohamad mran

      please whatsapp 0139671048

    3. Amirul Adib

      whatapp or telegeram me at 0194118978. prefer using telegram

    Comment

    Skills required:

    Category:

    FREELANCER BIDDING (0)
    BID
    There are no bids yet.
    ABOUT EMPLOYER

    nhme hashim

    Member Since June 11, 2019
    • Address:
    • Total spent: MYR0.00
    • Project posted: 1
    • Complete project(s): 0