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

174
Vistas
Can someone please assit me as to why this constant is returning null

the error message I keep getting Uncaught TypeError: form.querySelector(...) is null everything was working fine up until a while ago so i must of changed something that i dont know about file:///C:/Users/Ben/Documents/download text file/v12/v12 test .html:35

<html>
<form name="addtext">
<table>
<tr>
        <tr>
            <th> Fan Delay </th>
            <th><input id="fanDelay" type="text" name="fanDelay" value="0"   /></th>
        </tr>
        
</table>
    <table class="center">  
        <th></th>
        <th> <input type="submit" name="name" value="Save File" placeholder="File Name" /> </th>
    </table>
 </form>

</html>


<script>

/* Run script after DOMContentLoaded event to ensure form element is 
present */
document.addEventListener("DOMContentLoaded", function() {
  /* Obtain form element via querySelector */
  const form = document.querySelector('form[name="addtext"]');

  /* Bind listener to forms submit event */
  form.addEventListener("submit", function(event) {
    /* Prevent browsers default submit and page-reload behavior */
    event.preventDefault();

    
    var fanDelay   = form.querySelector('select[name="fanDelay"]').value;

        
    //
    const text =
`TACm Settings
VER
PRO
dt:  ${fanDelay}
    `;

    /* Create temporary link element and trigger file download  */
    const link = document.createElement("a");
    const href = "data:text/plain;charset=utf-8," + encodeURIComponent(text);
    link.setAttribute("href", href);
    link.setAttribute("download", "usb.txt");

    document.body.appendChild(link);

    link.click();

    document.body.removeChild(link);
  });
});

</script>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I think the error comes from here form.querySelector('select[name="fanDelay"]').value

You are using <input> tag, so just simply change that to this form.querySelector('input[name="fanDelay"]').value

about 4 years ago · Juan Pablo Isaza Denunciar

0

you trying to queryselector a select instead of input

try this :

var fanDelay   = form.querySelector('input[name="fanDelay"]').value;
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