I have 2 dropdown select in a HTML modal, one is for teams and the other is for players.
Teams dropdown select data are extracted from a DB. Each player is assigned to a team.
What I'm trying to do is when I change the teams dropdown select, the players dropdown select change according to the selected team which means it will contain only the players of the selected team.
==> I want to do that without CLOSING the modal and without REFRESHING the page.
<select id="teams" name="teams">
<?php
$sql = $bdd->query('SELECT * FROM teams;');
while($fetch = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
<option id="opt-<?php echo $fetch['id_team']; ?>"><?php echo $fetch['name']; ?></option>
<?php } ?>
</select>
<select id="players" name="players">
<?php
$sql = $bdd->query('SELECT * FROM players where id_team=...;');
while($fetch = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
<option id="opt-<?php echo $fetch['id_player']; ?>"><?php echo $fetch['name']; ?></option>
<?php } ?>
</select>
How can this be done ?