Trending

how to change input box value according to two select boxes in php using javascript

i have a form in php which has two select boxes and one input box first select contain the car model, second select contain hours and days option, in my database i have different prices for hours and date for each cars, so in input box i want that price to come accordingly, i did the following till now:

 

<div class="ip"><label>Select Car </label><br>
  <select name="cmodel" onchange="myFunction(this)">
    <option value="">---Select---</option>
    <?php
    $queryuserss = "SELECT * FROM cars";
    $dbs = mysqli_query($con, $queryuserss);
    while ( $ds=mysqli_fetch_assoc($dbs)) {
  echo "<option data-hours='".$ds['hprice']."' data-days='".$ds['dprice']."' value='".$ds['car']."'>".$ds['car']."</option>";
}
    ?>
  </select>
</div>

<div class="ip"><label>Choose Rent Type</label><br>


  <select name="hours" onchange="myFunctionz(this)">
    <option value="">---Select---</option>
    <option value="hours">Hours</option>
    <option value="days">Days</option>
    <option value="lease">Lease</option>

  </select>
</div>
<div class="ip"><label>Rate</label><br>
  <input type="text" name="crate" id="mytexts" value="" readonly/>
</div>

 

can anyone please tell me how to do this, thanks in advance