Dynamically add some text and text boxes to existing web page
<p>I am trying to create a number of text boxes with specific captions in front of each text box, dynamically.</p>

<p>I want the actual jquery code to create the textboxes and labels to lie within the following for loop---</p>

<pre><code>function addelements(){

    jQuery('&lt;form action="test" id="data-form" name="data-form" method="POST" onsubmit="senddatafinal();"&gt;  &lt;p&gt; This is a new form &lt;/p&gt;&lt;br /&gt;First name: &lt;input type="text" name="firstname" /&gt;&lt;br /&gt;Last name: &lt;input type="text" name="lastname" /&gt;').appendTo('body');
    for(i=0; i&lt;=3; i++)
    {      
         textmessage= "This is element # " + (i+1);
         fieldname= "field_" + (i+1);
     //now add code to show label stored in 'textmessage' 
     //to the form 'data-form'
     //now add code to show text box with name stored in 'fieldname' 
     //to the form 'data-form'
    }
}
</code></pre>
