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

142
Views
change the select input on change of other select input

i have more than 2 divs that have 2 select inputs. when i change branch_country, the other branch_region changes according to branch_country value via ajax.

<div>
   <select class="branch_country></select>
   <select class="branch_region></select>
</div>
<div>
  </elect class="branch_country></select>
  <select class="branch_region></select>
</div>

and here is my ajax code

    $('.branch_governorate_select').on('change', function(e) {
        e.preventDefault();

        console.log($(this).eq($(this)));

        var countryID = $(this).val();

        var status = $(this).parent().parent().find('.modal-body').find('#select-status-calendar')
            .val();

        var url = "{{ route('sett.doc_get_branch_region', ':id') }}";
        url = url.replace(':id', countryID);

        if (countryID) {
            $.ajax({
                url: url,
                type: "GET",
                dataType: "json",
                success: function(data) {
                    region_input.empty();
                    $.each(data, function(key, value) {
                        region_input.append('<option value="' +
                            value.id + '">' + value.name + '</option>');
                    });
                }
            });
        } else {
            region_input.empty();
        }
    });

it works well, but it changes all inputs with class branch_region. but i need to change only the branch_region select input that is inside the same div

about 4 years ago · Santiago Trujillo
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!