Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!