title: How to send buttons to input box?
body: <p>I'm trying to send buttons from end result to new input box but have no idea.
  I have tried several things.</p>
  
  <p>First</p>
  
  <pre><code>for (i=0;i&lt;res.length;i++) {
    var newbutton = document.createElement("BUTTON");
    var t = document.createTextNode("  "+res[i]);
    newbutton.appendChild(t);
    newbutton.style.marginRight = "10px";
    document.body.appendChild(newbutton);
    document.getElementById("demo").addEventListener("click",ansFunction);
    function ansFunction() {
    document.getElementByid("demo").innerHTML = "answers";
  }
  }
  </code></pre>
  
  <p>Second</p>
  
  <pre><code>for (i=0;i&lt;res.length;i++) {
    var newbutton = document.createElement("BUTTON");
    var t = document.createTextNode("  "+res[i]);
    newbutton.appendChild(t);
    newbutton.style.marginRight = "10px";
    document.body.appendChild(newbutton);
    newbutton.onclick = "ansFunction";
    function ansFunction() {
    document.getElementByid("demo").innerHTML = "answers";
  }
  }
  </code></pre>
  
  <p>But they dont work.
  Thank you in advance. </p>