title: how to auto calculate price and quantity and then display the result? AJAX PHP
body: <p>I am creating this simple project that includes auto calculate of the price and quantity and then display it only after two &lt; select > tags has been triggered,set or selected using <strong>AJAX</strong> without using submit button. I can achieve this but does not automatically calculates and display it without using submit button.  </p>
  
  <p>this is my code in HTML:</p>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;select name="days"&gt;
          &lt;option value="2"&gt;2 days&lt;/option&gt;
          &lt;option value="3"&gt;3 days&lt;/option&gt;
      &lt;/select&gt;
      &lt;select name="persons"&gt;
          &lt;option value="2"&gt;2 persons&lt;/option&gt;
          &lt;option value="4"&gt;4 persons&lt;/option&gt;
          &lt;option value="6"&gt;6 persons&lt;/option&gt;
          &lt;option value="8"&gt;8 persons&lt;/option&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Assume that in my <strong>Database</strong></p>
  
  <p>day 2 == 1000</p>
  
  <p>day 3 == 2000</p>
  
  <p>this is my code in PHP: </p>
  
  <pre><code>if(isset($_POST['submit'])) {
  
      $days     = $_POST['days'];
      $persons  = $_POST['persons'];
  
      // get database of the 'price' from rates tbl 
      $sql = "SELECT * FROM rates WHERE duration='$days'";
      $res = mysqli_query($conn,$sql);
  
          $rates_tbl = mysqli_fetch_assoc($res);
  
      $rates = $rates_tbl['price'];
  
      $total_price = ($rates*$persons);
  
      echo 'total: ' . number_format($total_price) . '.00';
  
  }
  </code></pre>
  
  <p>Should i use this type of ajax?? I dont even know if this is right.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt; 
         $.ajax({  
              url:"autocalculate.php",  
              method:"POST"
         }) 
      &lt;/script&gt;
  </code></pre>