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

275
Views
replacing HTML text with date from text file

I'm trying to Figure out how to replace HTML text using js code, the goal of it is the read a "1.txt" file with a name and replace the HTML text (Replace me!!) if anyone can help me and point me in the right direction.

here is what I have now

<body class="htmlNoPages">
  
<div id="main"><p>Replace me!!</p></div>

</body>
<script type="text/javascript" id="gwd-init-code">
    function load() {
      // var text = ('test 123')
      var file = new XMLHttpRequest();
        file.open(GET,'file:///d:/1.txt', true);
        file.responseType =Text;      
        file.onreadystatechange = function() {
        if (file.readyState === 4) { // Makes sure the document is ready to parse
          if (file.status === 200) { // Makes sure it's found the file
          text = file.responseText;
          }
        }
      }
let element = document.querySelector('#main');
element.innerHTML = text;  
}   
window.onLoad = load();

</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I did it like this

var TxtFile = new XMLHttpRequest();
TxtFile.onreadystatechange = function () {
    var allText = "Uw browser is niet compatibel of u heeft uw java script disabeld staan";
    if (TxtFile.readyState === XMLHttpRequest.DONE && TxtFile.status == 200) {
        allText = TxtFile.responseText;
        allText = allText.split("\n").join("<br>");
    }

    document.getElementById('planning').innerHTML = allText;
}
TxtFile.open("GET", 'File location', true);
TxtFile.send(null);

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