Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda