title: String building with Javascript document.write
body: <p>I am trying to write a div element from javascript. I want the line written as follows, using document.write():</p>
  
  <pre><code>&lt;div class="Square15px" onmouseover="changeColor('boxid')"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I call the function that writes the div element with: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
        colorPicker("box1");
   &lt;/script&gt;
  </code></pre>
  
  <p>I have tried the document.write() method, building the string several different ways such as:</p>
  
  <pre><code>function colorPicker(box) {
      var box = document.getElementById(box);
      var boxid = box.id;
      var AquaStr1 = '&lt;div class="AquaSquare15px" onmouseover="changeColor("';
      var AquaStr2 = '")&gt;&lt;/div&gt;';
  
      var AquaString = AquaStr1.concat(boxid, AquaStr2);
      document.writeln(AquaString);
  }
  </code></pre>
  
  <p>I have also tried splitting up the string many different ways using + as concat operator. The string builds incorrectly at the end of boxid. I get the same result no matter how I write the code block:</p>
  
  <pre><code>&lt;div class="AquaSquare15px" onmouseover="changeColor(" box1?)=""/&gt;
  </code></pre>
  
  <p>I just can't seem to see my error here, I have reviewed all of the help I can find. With the exception of the space between the quote and box1, everything is correct up until the mysterious question mark.
  I reviewed the results from IE9 developer tool (F12). I am not an experienced programmer, so I suspect I am in error somehow.</p>