从表单选项中获取ID并使用它来填充多个字段

I have looked throughout the site and nothing has quite matched what I'm after. I have a form which starts of asking the client to choose the company name from a dropdown. The dropdown is populated from a query as such:

<select name='company_name' id='dropdown'><?php     
$result = mysqli_query($con,"SELECT ID, TITLE FROM b_crm_company");
while($row = mysqli_fetch_array($result))
{
$companyName = $row['TITLE'];
$companyID = $row['ID'];
print "<option value='$companyID'>$companyName</option>";
}
?></select>

I then have 3 forms text fields that I need pre-populating based on what is selected from the above and I'm not sure how to do it. So my next three form fields:

<input type="text" value="$contactName" name="contactName">
<input type="text" value="$contactTelephone" name="contactTelephone">
<input type="text" value="$contactEmail" name="contactEmail">

The select statement I'd need to get these three values:

SELECT COMPANY_ID, NAME, TELEPHONE, EMAIL FROM b_crm_contact 
WHERE COMPANY_ID = $companyID

The $companyID obviously being pulled from the dropdown at the start. How can I pull the information to the next fields? I'm assuming javascript but not sure how to write it.

Thanks in advance

you need to call ajax on click of your drop down select item and then need to return string or json from that php file and then parse and put values in appropriate fields

something like this:

$("button").click(function(){
  $.ajax({url:"demo_test.txt",success:function(result){
    $("#div1").html(result);
  }});
});