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

150
Vistas
AngularJS days dropdown does not update when month dropdown changes

I am working on DOB validation in AngularJS. However I am facing an issue. Whenever I'm changing the month from the dropdown, the days dropdown won't get updated on the first click of the dropdown. So technically, I have to select first a random number of the days dropdown, only then the number of days will get updated on the second click, depending on the selected month. The days array is updating after the clicking any month in dropdown, but it is not updating the days in days dropdown. Sharing this code snippet. Any advice? Thanks.

$(document).ready(function () {
$('#monthOfBirth').change(function () {

var e = document.getElementById('monthOfBirth');
var monthValue = e.options[e.selectedIndex].value;
var monthLength = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var setNumberOfDays = monthLength[monthValue - 1];
console.log(monthValue, setNumberOfDays);

function populateDays() {
  const days = [];
  for (let i = 1; i <= setNumberOfDays; i += 1) { //
    if (i < 10) {
      days.push({ value: `0${i}`, text: `0${i}` });
    } else {
      days.push({ value: i, text: i });
    }
  }
  return days;
}
function populateMonths() {
  const months = [];
  for (let i = 1; i <= 12; i += 1) {
    if (i < 10) {
      months.push({ value: `0${i}`, text: `0${i}` });
    } else {
      months.push({ value: i, text: i });
    }
  }
  return months;
}
function populateYears() {
  const years = [];
  for (let i = 1950; i <= new Date().getFullYear(); i += 1) {
    years.push({ value: i, text: i });
  }
  return years;
}

$scope.dayOfBirth_items = populateDays();
$scope.monthOfBirth_items = populateMonths();
$scope.yearOfBirth_items = populateYears();

}); })

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