x
<select id="countrySelect" onchange="changeBackgroundColor()">
<option value="usa">USA</option>
<option value="uk">UK</option>
<option value="france">France</option>
</select>
<script>
function changeBackgroundColor() {
const selectedCountry = document.getElementById("countrySelect").value;
if (selectedCountry === "usa") {
document.body.style.backgroundColor = "red";
} else if (selectedCountry === "uk") {
document.body.style.backgroundColor = "blue";
} else if (selectedCountry === "france") {
document.body.style.backgroundColor = "white";
}
}
</script>