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 do a cascade filtering using javascript

I have a table a such

Env depot articles
100 AAA Capacitor
100 AbA Diode
100 AAA cable
100 AbA mike
100 ABC modem
900

Im extracting my data from a postgres database using php and it's working fine

Now i'm wanting to do a cascade filter to show for a specific Env the depot associated and the articles under that articles depot

For example , if i select in my dropdownlist Env = 100 , dropdownlist dépot would show me AAA / AbA / ABC then when i select AAA dropdowlist Articles will show Capacitor / cable

if i select in my dropdownlist Env = 900 , dropdownlist dépot would show me nothing so on in dropdowlist Articles

This is a sample of Data but my table contains more values .

Here is my code that tried but couldn't reach desired output

var options = $('#env').val();
var selectOptions = '';

for (i = 0; i < options.length; i++) {
  selectOptions += '<option value="' + options[i] + '">' + options[i] + '</option>';
}

$('#env').append(selectOptions).on('change', function() {
  var selected = $(this).find('option:selected').val();

  $('#depot, #articles').empty();

  $.each(envs, function(i, v) {;
    if (v.env == selected) {
      $('#depot').append('<option value="' + v.depot + '">' + v.depot + '</option>');
      $('#articles').append('<option value="' + v.articles + '">' + v.articles + '</option>');
    }
  });
});
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!