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

295
Vistas
JavaScript document.body.innerHTML+= undoes changes to existing input fields in html form

I am using the following inline script to overlay a help file that shows until you click, the reverts to the original content by removing the dom element. As soon as the document.body.innerHTML+=C; is executed, the checkboxes and data entry fields changed since page load are undone. I know it is completed then because the overlay is partially transparent and I can see that this line of code unchecks boxes and empties fields.

Here is my inline script:

        {let Content="";let c="No help content found";
        const today = new Date();const year = today.getFullYear();
        let C="<div style=\'position:fixed;z-index:110;top:0;left:0;width:100%;height:100%;font-size:16pt;";
        C+="color:#000000;background-color:#ccccff;font-family:sans-serif;font-style:normal;font-variant:normal;opacity:0.92;font-weight:normal;";
        C+="padding:0px;margin:0px;border:0px;border-style:solid;border-color:#85bb65;overflow:auto;\'";
        if (U !== undefined) {Content="";let http=new XMLHttpRequest();http.open("GET", U, false);http.send();Content=http.responseText;}
        if (Content !== "") {c=Content;}
        C+=" onclick=\"this.remove()\">";
        C+="<div style=\'width:98%;margin:auto;\'><center><table border=4><tr><th onclick=\"this.parentNode.parentNode.remove();\">Click to Close<b\
r></th></tr></table><b style=\'font-size:10px;\'>Copyright &copy; Fred Cohen, 2022-"+year+"</b></center>"+c+"</div></div>";
        document.body.innerHTML+=C;
        return("");};```

Does anybody know why this is? And is there anything I can do about it other than to first collect all content from all fields and restore it all so this little routine will not clear fields? What am I missing here?
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