title: How To Get an HTML element from another HTML document and display in current document?
body: <p>I'm building a web site which lets users post requests on site and others to respond. I have built an app-like form to collect information. In that form I need to display 3 pages.</p>
  
  <p>So I have created one page with the from and and a JavaScript file to handle these 3 pages. Other form-pages are designed separately (HTML only).</p>
  
  <p>I'm planning to load the other two pages into that 1st page with XMLHttpRequest and it works.</p>
  
  <p>But I need to take 3rd page into the 1st form-page (display the 3rd page of form) and change the innerHTML of that 3rd page. I tried it with</p>
  
  <pre class="lang-js prettyprint-override"><code>function setFinalDetails() {
    document.getElementById("topic").innerHTML = object1.start;
  }
  
  //creating a XMLHttpObject and sending a request
  //requiredPage is the page we request. 
  //elementId is the element we need to display
  
  function requestAPage(requiredPage) {
  
    selectElementId(requiredPage);
    var xhttp = new XMLHttpRequest();
  
  
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
        m = xhttp.responseXML;
        y = m.getElementById(elementId).innerHTML;
        document.getElementById("hireForm").innerHTML = y;
  
        //m is a global variable
        //m is the object recieved from XMLHttpRequest.
        //it is used to change the innerHTML of itself(m) and display.
  
        //y is displaying the 3rd page in the form-page one("id =hireForm")
  
        return m;
      }
    };
  
    xhttp.open("GET", requiredPage, true);
    xhttp.responseType = "document";
    xhttp.send();
  }
  </code></pre>
  
  
  
  <p>but that gives an error: </p>
  
  <blockquote>
    <p>Cannot set a .innerHTML property of null</p>
  </blockquote>
  
  <p>find my work on <a href="https://github.com/infinitecodem/Taxi-app-form.git" rel="nofollow noreferrer">https://github.com/infinitecodem/Taxi-app-form.git</a></p>