Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
How to filter select options based on another select in jQuery using dictionaries?

In first select I choose my species, so in next select i want choose breed from my choosen species. Example: When I choose Cat-species I want see only Ragdoll and Maine Coon in my breeds select, without Yorkshire Terrier because it is a dog. It doesn't work and I don't have any idea how to do that. Now it is : ERR_INCOMPLETE_CHUNKED_ENCODING 200

HTML:

<div class="form-row">
                    <div class="form-group col-md-6 text-center">
                        <label for="species-create" th:text="#{animal.species}"></label>
                        <select id="species-create" class="form-control">
                            <option th:each="species : ${speciesDict}"
                                    th:value="${species.id}"
                                    th:text="${species.value}">
                            </option>
                        </select>
                    </div>
                    <div class="form-group col-md-6 text-center">
                        <label for="breed-create" th:text="#{animal.breed}"></label>
                        <select id="breed-create" class="form-control">
                            <option th:each="breed : findBreeds()"
                                    th:value="${breed.id}"
                                    th:text="${breed.value}">
                            </option>
                        </select>
                    </div>
                </div>

JavaScript

function findBreeds() {
         $.ajax({
             url: "/admin/api/breeds?" + prepareBreedsUrl(),
             type: "get",
             dataType: "json",
             contentType: "application/json"
         })
         .done(function (response) {
             return response;
         })
         .fail(function(jqxhr, textStatus, errorThrown){
             displayErrorInformation(jqxhr.responseText);
         });
}

function prepareBreedsUrl(){
       var species = $("#species-create").find(":selected").val();
          if (species != "") {
             url += "&species=" + species;
          }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!