0
I need the select of cities to have options according to the chosen state.
<!DOCTYPE html>
<html>
<head>
<title>estados</title>
<meta charset="utf-8">
</head>
<body onload="mods()">
Estado: <select id="estados">
<option></option>
</select><br><br>
Cidade: <select id="cidades">
<option></option>
</select>
</body>
</html>
<script type="text/javascript">
var arrayEstados = ['Rio de Janeiro','São paulo','Minas Gerais']
var rj = {
nome: 'Rio de Janeiro',
cidades: ['Belford Roxo','São joão de meriti','Duque de Caxias'],
}
var sp = {
nome: 'São paulo',
cidades: ['Diadema','Bauru','Suzano'],
}
var mg = {
nome: 'Minas Gerais',
cidades: ['Belo Horizonte','Betim','Contagem'],
}
</script>
'''
I am layman still in javascript, sorry I can not explain in a clearer way. But what I want is the same that some sites have. for example, according to the chosen state, in the other select appears only the cities of that state.
– Allan Cisneiro
Tip: Present your problem in an abstract way. Do not directly use problem code. Make a reduced version, without your business rule, no lines of code that are not directly linked to the problem. So your question becomes clearer for yourself to better elaborate the question, clearer for others to answer and more generic to help others in the future..
– Aurium
blz friend I will review and edit
– Allan Cisneiro
Friend put only html and the objects that should appear in options. can help?
– Allan Cisneiro
Buddy, there’s a question right here at stackoverflow that I think helps you. https://answall.com/questions/69802/filtrar-estados-e-cidades-da-biblioteca-cidades-estados-js
– Thi100