title: how to set textbox value from sql database on changing combo box option?
body: <p>I am having this school project that confuses me big time (it seems so simple though)..
  So here's the deal, I need to set the value of a textbox based on the selections of combobox. Here's what I got so far</p>
  
  <pre><code>    &lt;?php require_once( str_replace('//','/',dirname(__FILE__).'/') . 'library/SfCrud.php' );   
        $sfCrud = new SfCrud();
        $resultSupplier = $sfCrud-&gt;read('select * from supplier');
      ?&gt;
  
       &lt;form action="" method="post"&gt;
       &lt;div align="center"&gt;
         &lt;table&gt;  
         &lt;tr&gt;
           &lt;td colspan="3"&gt;&amp;nbsp;&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
           &lt;td colspan="3"&gt;Supplier Information&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
           &lt;td&gt;Supplier  &lt;/td&gt;
           &lt;td&gt;:&lt;/td&gt;
           &lt;td&gt;
             &lt;select style="width:100%" id='slcSupplier' name="slcSupplier"&gt;
               &lt;?php foreach($resultSupplier as $row){?&gt;
           &lt;option  value="&lt;?php echo($row-&gt;supplierID);?&gt;"&gt; &lt;?php echo($row-&gt;supplierID.' : '.$row-&gt;name);?&gt;
               &lt;/option&gt; &lt;?php }?&gt;
             &lt;/select&gt;
           &lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
           &lt;td&gt;Address&lt;/td&gt;&lt;td&gt;:&lt;/td&gt;
           &lt;td&gt; &lt;textarea id="txtAddress" name="txtAddress"&gt;&lt;/textarea&gt; &lt;/td&gt;
         &lt;/tr&gt;
         &lt;/table&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>I need to get the address of the selected supplier from the database database and show it on the text area without refreshing the whole page.. thanks for helping..</p>
  
  <p>i hv reworked my codes after reading the answers</p>
  
  <pre><code>   &lt;?php require_once( str_replace('//','/',dirname(__FILE__).'/') . 'library/SfCrud.php' );    
     $sfCrud = new SfCrud();
     $resultSupplier = $sfCrud-&gt;read('select * from supplier');
  
     ?&gt;
  
     &lt;script&gt;
     $(document).ready(function(e)
     {
    $("#slcSupplier").change(function(){
      var id = $(this).val();
  
      $.ajax({
          url: 'supplier.php',
          method: 'POST',
          data: "id=" + id,
          success: function(data)
          {
              $('#txtAddress').html(data);
          }
      }); 
  });
      });
      &lt;/script&gt;
  
      &lt;div&gt; 
  
      &lt;table&gt; 
       &lt;tr&gt;
         &lt;td colspan="3"&gt;
           &lt;input type="button" name="a" id="a" value="Submit" /&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
         &lt;td colspan="3"&gt;Supplier Information&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
        &lt;td&gt;Supplier  &lt;/td&gt;
        &lt;td&gt;:&lt;/td&gt;
        &lt;td&gt;
          &lt;select style="width:100%" id='slcSupplier' name="slcSupplier"&gt;
          &lt;?php foreach($resultSupplier as $row){?&gt;
          &lt;option  value="&lt;?php echo($row-&gt;supplierID);?&gt;"&gt;
                &lt;?php echo($row-&gt;supplierID.' : '.$row-&gt;name);?&gt;
              &lt;/option&gt; &lt;?php 
       }?&gt;
          &lt;/select&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
         &lt;td&gt;Address&lt;/td&gt;&lt;td&gt;:&lt;/td&gt;
         &lt;td&gt;
            &lt;textarea id="txtAddress" name="txtAddress"&gt;&lt;/textarea&gt;
         &lt;/td&gt;
       &lt;/tr&gt;
  
  
    &lt;/table&gt;
  </code></pre>
  
  <p>i dont know what's wrong, but the javascript doesnt work.. im so clueless here..</p>