0 Replies - 449 Views - Last Post: 03 February 2020 - 09:07 AM Rate Topic: -----

#1 emanuel2020   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-February 20

How to get selected values from different drop downs and populate them

Posted 03 February 2020 - 09:07 AM

am creating a valuation website using PHP, MYSQL, a bit of JQUERY and Javascript. In my database I have 3 tables:

id make
Table "model":

model_id model_name make_id
1 M3 1
Table "car_attributes":

car_id make_id model_id year mileage cylinder price market_value
1 1 1 2019 5000 3.6 5000 5200

n the user's page I have different drop downs where the user can select the makes, models, year, mileage, cylinder and son on. Once the user has made all the selections from the drop downs and the user clicks the evaluate button, I want to get the price,value and other results of that specific car only based on the ID of the car_attributes and populate those values in text boxes. I have done the code using javascript but it only returns records of for example the year when the onchange event is trigger. I would like to make the selections first then when the user clicks a button it should return all the records of that specific car ID.
here is the code I have so far.

  <div class="col-xs-3">
      <label for="get_car_year">Year</label>
       <select name="get_car_year" class="form-control item_category" 
           id="get_car_year" onchange="getDetails()">
          <option value="0">-- Select --</option>


            $query = "SELECT DISTINCT year, price_in_ead, current_rate_dollar 
              from car_attributes ORDER BY year DESC";

           $result = mysqli_query($con, $query);

           while($row = mysqli_fetch_row($result)) {
               echo "<option data-price_in_ead='$row[1]'  data- 
             rate_in_dollar='$row[2]'  value='$row[0]'> $row[0] </option>";




    function getDetails(){
        var price = $('#get_car_year').find(':selected').data('price_in_ead');
        var rate = $('#get_car_year').find(':selected').data('rate_in_dollar');


This post has been edited by astonecipher: 03 February 2020 - 09:12 AM
Reason for edit:: code tags

Is This A Good Question/Topic? 0
  • +

Page 1 of 1