title: How do I write a variable in javascript from getelementbyid
body: <p>This is probably a simple question ( or I assume to be ) however, I still can't get it to work no matter how much i twinker with it. I am trying to write a variable inside a li tag. This variable should hold the text within another div tag like so:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var item = document.getElementById('thistext').innerHTML;
                      function songlist () {
  document.write("&lt;div class='overview'&gt;&lt;ul&gt;&lt;li&gt; item &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;");
  }
  &lt;/script&gt;
  
  
  &lt;div id="thistext"&gt;hello&lt;/div&gt;
  
  &lt;!-- I want it to appear here --&gt;
  &lt;div class="viewport"&gt;
  &lt;script type="text/javascript"&gt;
  songlist ();
  &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So basically I need the text within "thistext" div tag to appear within the li tag which is within the ul etc (I don't know if thats unnecessary info or not ) I've also tried putting the script and its function within the viewport tag itself and with:</p>
  
  <pre><code>document.getElementById("id").innerHTML = "value";  
  </code></pre>
  
  <p>that layout too but it doesn't appear to be showing working and I can't seem to understand why. I'm looking forward to the responses and thanks in advance.</p>