title: How to add a text box on a button click?
body: <p>I am writing a JSP page where an admin can prepare the question format for the users. All the questions have multiple choices ranging from 2 (for yes or no) to 5. I want to provide a button for the admin which on click has to generate a text box corresponding to 1 answer. This button should also check that the answer boxes have not exceeded 5 as there can be no more than 5 multiple choices. </p>
  
  <p>How can I go about this problem? How to stuff the JavaScript variable inside the <code>innerHTML</code>? I have done something like this:</p>
  
  <pre><code>function addAnswer(queryNum, ansCount){
      var d=document.getElementById("div");
      var i = queryNum;
      alert(i);   
      var j = ansCount;
      alert(j);   
      d.innerHTML+="&lt;label class='optsurvey-answer' for='answer_'&gt;Answer&lt;/label&gt;"+"&lt;input class='optsurvey-answerinput' type='text' name='&lt;portlet:namespace /&gt;answer_'&gt;";
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here <code>queryNum</code> and <code>ansCount</code> are params passed by JSP. I want to stuff them inside the <code>d.innerHTML</code>. Something like this</p>
  
  <pre><code>d.innerHTML+="&lt;label class='optsurvey-answer' for='answer_'&gt;Answer&lt;HERE I HAVE TO STUFF "ansCOUNT" &gt;&lt;/label&gt;"+"&lt;input class='optsurvey-answerinput' type='text' name='&lt;portlet:namespace /&gt;answer_'&gt;";
  </code></pre>