no of input fields according to user input
<p>I have a form that will ask number of input fields from user, and then append inputs to the form. I have developed the function using JavaScript. </p>

<p>The problem is for the first time it will work fine. If I again select another number from the select tag, it will append the number of input fields to the previous inputs.</p>

<p>Example:</p>

<ul>
<li>If I first select 4 input fields it will show 4 input fields. </li>
<li>If I again select 2 from the select tag it will add another two input
fields.</li>
</ul>

<p>So altogether 6 input fields. I don't want that. If I select 4 it should be 4. If I again select 2 it should be 2, not 6. Here is my code:</p>

<pre><code>function obj(){

    var a=document.getElementById('no_of_obj').value; //select tag value(1 to 6)
    var b=document.getElementById('objBlock') //this is the container
    var i=0;

    while(i&lt;a){
        var txt=document.createElement('input');
        txt.type="text";
        txt.id="obj"+i;
        txt.style.height="30px";

        b.appendChild(txt);
        i++;
    }

}
</code></pre>
