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

89
Views
Import Case List for switch function in javascript

I'm learning by doing js and jQuery.

I have a geocoder input (mapbox) and I need to check if the entered address is eligible for a specific service.

More specifically, I need to check if the zipcode is in our database of supported areas. The input zipcode is defined as the variable "userplz".

In both cases (is available or is not available) a specific class is added to an html element for visual representation. Also the result get's saved to localStorage.

I'm doing this with:

switch (userplz) {
case '14129':
case '14532':
    $('#availability').append(available);
    availability.classList.add('available','pulse-green');
    localStorage.setItem('available',"yes");
    break;
default:
    $('#availability').append(unavailable);
    availability.classList.add('unavailable','pulse-red');
    localStorage.setItem('available',"no");
};

Now I don't want to edit the script every time we expand our service area. Ideally I'd save a file with eligible zipcodes somewhere in in the page directory and import the file into my script. Therefore I only have to update the file and not the script, every time we update our supported zipcodes.

Any help is appreciated. Best regards, Vincent

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!