I need the second <select>
to receive the data according to the choice of the first one. The <option>
appears in the first <select>
, but in the second it does not move.
I have a textdata
folder with all .txt for <option>
of each match.
HTML
<select id="first-choice">
<option selected value="0">>>> Selecione</option>
<option value="AC">AC</option>
<option value="AL">AL</option>
<option value="AM">AM</option>
<option value="AP">AP</option>
<option value="BA">BA</option>
<option value="CE">CE</option>
<option value="DF">DF</option>
<option value="ES">ES</option>
<option value="GO">GO</option>
<option value="MA">MA</option>
<option value="MG">MG</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="PA">PA</option>
<option value="PB">PB</option>
<option value="PE">PE</option>
<option value="PI">PI</option>
<option value="PR">PR</option>
<option value="RJ">RJ</option>
<option value="RN">RN</option>
<option value="RO">RO</option>
<option value="RR">RR</option>
<option value="RS">RS</option>
<option value="SC">SC</option>
<option value="SE">SE</option>
<option value="SP">SP</option>
<option value="TO">TO</option>
<option value="WW">WW</option>
</select>
<br>
<select id="second-choice">
<option>Selecionar UF</option>
</select>
JAVASCRIPT
<script src="https://code.jquery.com/jquery-1.10.2.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/JavaScript">
$("#first-choice").change(function() {
$("#second-choice").load("textdata/" + $(this).val() + ".txt");
});
</script>
A part of one of the .txt files
<option>São Paulo - SP001</option>
<option>Adamantina - SP002</option>
<option>Adolfo - SP003</option>
<option>Aguaí - SP004</option>
<option>Águas da Prata - SP005</option>