Avatar of David Schure
David Schure

asked on 

One list box dependent on another

When I select a name from the left list I want the right one to update accordingly. Right now nothing is happening.


Open in new window

<div id="tlist">   
<?php
$result = mysqli_query($con, "SELECT tbl_therapist.therapist_id, tbl_therapist.therapist_name FROM tbl_therapist ORDER BY therapist_name ASC;");
?>
<label><strong>THERAPIST</strong></label><BR>
<select name="my_therapist" id="my_therapist" size="10">
<?php
while ($row = mysqli_fetch_array($result)) {
    printf("<option value='%s'>%s</option>", $row['therapist_id'], $row['therapist_name']);
}
?>
</select>
</div> 

<div id="results">
 <?php
$result = mysqli_query($con, "SELECT tbl_client.client_id, tbl_client.client_name FROM tbl_client INNER JOIN tbl_therapist_client
ON tbl_therapist_client.client_id=tbl_client.client_id WHERE tbl_therapist_client.therapist_id = $therapist_id ORDER BY client_name ASC;");
?>
<label><strong>CLIENTS</strong></label><BR>
<select name="my_clients" id="my_clients" size="10">
<?php
while ($row = mysqli_fetch_array($result)) {
    printf("<option value='%s'>%s</option>", $row['client_id'], $row['client_name']);
}
?>
</select>   
</div>    

Open in new window

The left one is therapist.  the right one clients
PHP

Avatar of undefined
Last Comment
David Schure

8/22/2022 - Mon