I am inexperienced in javascript, and would like help in this case:
I have two selects in my document:
<select id="estado">
<option value="MG">MG</option>
<option value="SP">SP</option>
<option value="RJ">RJ</option>
<option value="RJ">BA</option>
</select>
<select id="cidade">
<option value="Belo Horizonte">Belo Horizonte</option>
<option value="Betim">Betim</option>
<option value="Contagem">Contagem</option>
</select>
The expected behavior is that when you click on a state option, it overrides the id = city selection. I believe that document.write is the solution, however, the content to be overridden should be taken into account the order of the option clicked on the select id = state and not its value.
For example:
The first option overrides the select city for:
<select id="cidade">
<option value="Sou o primeiro">Sou o primeiro</option>
</select>
The second option replaces the select city for:
<select id="cidade">
<option value="Sou o segundo">Sou o segundo</option>
</select>
The third one replaces the select city for:
<select id="cidade">
<option value="Sou o terceiro">Sou o terceiro</option>
</select>
The fourth replaces the select city for:
<select id="cidade">
<option value="Sou o quarto">Sou o quarto</option>
</select>
The biggest problem is that these values to be overridden must be referenced by the order in the select state, not by its value. That is, regardless of the value of the third option of the select #estate, it does not matter if it will be SP, RJ, MG or BA, when it is clicked, it will replace the other select with the third code above. If you click on the second option, it replaces the second code.
Well that's it. Thank you all for helping.