Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
Want to show show content of particular key in the dropdown form

I created a from where I need to take state and city or District from the user and I have Json file of all the information. I successfully able to fetch the Sates from that JSON file

  <label for="state">State</label>
   <select name="state" id="state">
   <option value="" selected="true" disabled="true">Select your State</option>
   </select>
 <label for="District">District</label>
         <select name="District" id="district">
            <option value="" selected="true" disabled="true">Select your district</option>
         </select>
<script>
$(document).ready(function(){
    var obj = "places.json";
    let data;
     $.getJSON(obj, function (info) {
         data=info;
        $.each(data, function (index, value) {
            $('#state').append('<option value="' + index + '">' + value.state + 
    '</option>');
      }); 
     });
});
</script>

JSON File content

{  
         "state":"Delhi (NCT)",
         "districts":[  
            "Central Delhi",
            "East Delhi",
   
         ]
      },
      {  
         "state":"Goa",
         "districts":[  
            "North Goa",
            "South Goa"
         ]
      },

What I want when user Select particular state from the dropdown box. then in the district all the districts of that particular state will display there is this possible to do

I try the same way to fetch the districts from the JSON but in drop down i am getting all districts of every state in object. What I want when user Select particular state from the dropdown box. then in the district dropdown all the districts of that particular state will display. Is this possible to do. Suppose I select Goa all districts of goa show in dropdown

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda