xxxxxxxxxx
1
<select id="agentNumberElement">
2
<option value="1">One</option>
3
<option value="2">Two</option>
4
<option value="3">Three</option>
5
<option value="4">Four</option>
6
<option value="5">Five</option>
7
<option value="6">Six</option>
8
<option value="7">Seven</option>
9
<option value="8">Eight</option>
10
</select>
11
12
<select id="brokerNumberElement">
13
<option value="1">One</option>
14
<option value="2">Two</option>
15
<option value="3">Three</option>
16
<option value="4">Four</option>
17
<option value="5">Five</option>
18
<option value="6">Six</option>
19
<option value="7">Seven</option>
20
<option value="8">Eight</option>
21
</select>
1
1
xxxxxxxxxx
1
const agentNumberElement = document.getElementById('agentNumberElement')
2
const brokerNumberElement = document.getElementById('brokerNumberElement')
3
4
// Event listener for the agent select
5
agentNumberElement.addEventListener('change', function () {
6
if (this.value !== "1") { alert('agent')
7
brokerNumberElement.value = 1;
8
}
9
});
10
// Event listener for the broker select
11
brokerNumberElement.addEventListener('change', function () {
12
if (this.value !== "1") {alert('broker')
13
agentNumberElement.value = 1;
14
}
15
});
Console errors: 0