title: Passing input to span field
body: <p>I am trying to pass the input i have from an input to an span field. I use an api dropdown list with results. So if people click on an search result it get autofilled in (much like google). I want to pass this result to an span field I have in my page.</p>
  
  <p>However I dont want an onclick event if people click on an result. Rather when people click out of the input field..</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>    &lt;div&gt;
          &lt;input id="exercise-search" class="form-control" type="text" name="data"&gt;
      &lt;/div&gt;
      &lt;span id="namespan"&gt;Name&lt;/span&gt;
  </code></pre>
  
  <p>And the simple script:</p>
  
  <pre><code>        &lt;script&gt;
  
              var name = document.getElementById("exercise-search").value;
              document.getElementById("namespan").textContent=name;
  
              function reload(){
                  var container = document.getElementById("namespan");
                  var content = container.innerHTML;
                  container.innerHTML= content;
              }
          &lt;/script&gt;
  </code></pre>
  
  <p>However I still have to manually refresh the page to see the result. How can i automate this?</p>