I hope the title wasn't too cryptic, and I am sure there will be other threads like this one but cannot seem to put my finger on the correct terminology.
I have a form that has 3 dropdowns. Let's call them 'sales consultant', sales email & sales team.
What I am looking to do is give a value to 'sales email' & 'sales team' when the sales consultant is chosen from the dropdown 'sales consultant'
The catch, I am using mysql to pull the data for each dropdown. See below:
<div id="sc">
Sales Consultant
<input class="" type="text" list="salesconsultant" name="salesconsultant" placeholder="Start typing consultants name" required />
<datalist id="salesconsultant">
<?php
$sql = "SELECT consultant, id FROM salesconsultants";
$result = $conn->query($sql);
if (!$result) die($conn->error);
if($result->num_rows > 0 ) {
while($row=$result->fetch_assoc()) {
echo "<option value=\"".$row["id"]."\">".$row["consultant </option>";
}
echo "</datalist>";
} else {
echo"record 0";
}
?>
</div>
The other rows I have in the database are 'salesemail', 'id', 'consultant' and 'teamid'.
So when sales consultant 1 is selected it will give the variable $salesemail the value of consultant 1's 'salesemail' and so on.
Is this possible?