title: Error parsing XHTML: The content of elements must consist of well-formed character data or markup
body: <p>As an extension of this <a href="https://stackoverflow.com/questions/4304132/hcommandbutton-multiple-actions-download-file-and-render-ajax-table">question</a>, I'm trying to insert Javascript to a <code>&lt;h:commandButton /&gt;</code>'s <code>onclick</code> property as <code>action</code> is already rendering an ajax table.</p>
  
  <p>What I want to do:
  Get the selected items in a list box and turn them into parameters to be used in a JSF <code>FileServlet</code>. i.e. <code>para2=value1&amp;param=value2&amp;param=value3</code></p>
  
  <p>Here's what I have:</p>
  
  <pre><code>&lt;script type ="text/javascript"&gt;
  function myScript() {
      var box = document.getElementbyId('myForm:box');
      var length = box.options.length;
      var paramstring = "";
      for (var i = 0; i &lt; length; i++) {
          if (i != (length - 1) {
              if (box.options[i].selected) {
                  paramstring = paramstring + "param=" + box.options[i].value + "&amp;amp;";
              }
          } else {
              paramstring = paramstring + "param=" + box.options[i].value;
          }
      }
      if (document.getElementById('myForm:checkbox').checked) {
          window.location='fileServlet? + paramstring;
      }
  }
  &lt;/script&gt;  
  </code></pre>
  
  <p>What I get when page is loaded:
  <code>javax.servlet.ServletException: Error Parsing /page.xhtml: Error Traced[line:15] The content of elements must consist of well-formed character data or markup.</code></p>
  
  <p>What doesn't trigger exception:</p>
  
  <pre><code>&lt;script type ="text/javascript"&gt;
  function myScript() {
      var box = document.getElementbyId('myForm:box');
      var length = box.options.length;
      var paramstring = "";
  
      if (document.getElementById('myForm:checkbox').checked) {
          window.location='fileServlet? + paramstring;
      }
  }
  &lt;/script&gt; 
  </code></pre>
  
  <p>As soon as I add in <code>for (var i = 0; i &lt; length; i++)</code> or even <code>for (var i = 0; i &lt; 10; i++)</code> the page wouldn't load. Why does it not like the for loop?</p>