first click on select displays bad
second click on select displays good
$(document).on("click", "#edit_afpDetalle_mes", function () {
actualizarSelectsMes('#edit_tabla_afp_detalle');
});
$(document).on("click", "#btnEliminarFilaEdit", function () {
eliminarFila(this);
});
function actualizarSelectsMes(id_input) {
// Obtener todos los meses seleccionados en las filas existentes
var mesesSeleccionados = [];
document.querySelectorAll(id_input + ' tbody select').forEach(function (select) {
if (select.value !== '') {
mesesSeleccionados.push(select.value);
}
});
// Actualizar cada select en la tabla
document.querySelectorAll(id_input).forEach(function (select) {
select.querySelectorAll('option').forEach(function (option) {
// Si la opción está seleccionada en otro select, ocultarla
if (mesesSeleccionados.includes(option.value) && option.value !== select.value) {
option.style.display = 'none';
} else {
option.style.display = 'block';
}
});
});
}
The select should show the options as in the second image, but a lag occurs first, all the options are shown and the selected ones are quickly hidden.