I would like help to implement an onchange event in a select field of the form where, when changing that field, the new value of the option interacts with PHP/Mysql to change the value of another input field in the form.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<label for="teams">Select your team:</label>
<select id="team" onchange="selectTeam()">
<option value="sampa">São Paulo</option>
<option value="rio">Rio de Janeiro</option>
<option value="curitiba">Curitiba</option>
<option value="salvador" selected>Salvador</option>
<option value="floripa">Florianópolis</option>
</select>
<div id="info">
</div>
</body>
<script>
selectTeam()
function selectTeam(){
let team = document.getElementById('team').value
document.getElementById('info').innerHTML = `You have selected ${team} team`
}
</script>
</html>
This code performs the necessary interaction without using a DB query.
I only got local interaction in JS but it would really need interaction with the database.
Thank you very much.