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

259
Vistas
JavaScript function is not defined in Django

I have a small Django project. I have a JS script in the HTML file for one of my apps:

<script type="text/javascript">
    function intervalSelector() {
        let intervalField = document.getElementById("intervalField");
        let hourField = document.getElementById("hourField");
        let minuteField = document.getElementById("minuteField");

        intervalField.addEventListener("change", function () {

            if (intervalField.value === "Hourly") {
                hourField.disabled = true;
                minuteField.disabled = false;
            } else {
                hourField.disabled = false;
                minuteField.disabled = false;
            }
        });
    }
</script>

This function is called by a button element further down in the HTML document:

<button style="background-color: orange; color: white; float:left; margin-right:5px;"
        class="btn" type="button"
        onclick="intervalSelector()"
        data-bs-toggle="collapse"
        data-bs-target="#collapseWidthExample" aria-expanded="false"
        aria-controls="collapseWidthExample">
        Schedule
</button>

The function gets three elements by their Id in the HTML document:

<select class="form-select form-select-lg mb-3"
        aria-label=".form-select-lg example" id="intervalField">
        <option selected>Interval</option>
        <option value="1">Daily</option>
        <option value="2">Hourly</option>
</select>

<input name="hour" class="form-control" type="number" min="0" max="23" value="23" id="hourField">
<input name="minute" class="form-control" type="number" min="0" max="59" value="57" id="minuteField">  

When I run my webapp, and click the button that calls the function, it says that the intervalSelector function is not defined. Any ideas on what the problem could be?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you have a mistyping in your function definition, the ); shouldn't be there, at line -2

about 4 years ago · Juan Pablo Isaza Denunciar
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