setting values of textfields using jquery
<p>I am trying to create a simple html file containing the monthly salary of employees and must calculate the tax payable for each salary!
I use an "add" button to add more employee textfield which creates a new class of div containing the similar div!
On onchange event of the salary textfield I can not set the tax value of the appropriate employee!</p>

<p>Unfortunately I can not upload the screenshot so I put all code to make my question as clear as possible!</p>

<p>This is the jquery code for adding employee area:</p>

<pre><code>$(document).ready(function(){

var counter = 2;

$("#add_emp").click(function () {


var newTextBoxDiv = $(document.createElement('div'))
     .attr("class", 'em_area' + counter);

newTextBoxDiv.after().html('&lt;br&gt;&lt;label&gt;Employee '+counter+' &lt;/label&gt; &lt;input id=em_name name=em_name type=text required  /&gt; &lt;label&gt;Position&lt;/label&gt; &lt;input id=em_post name=em_post type=text required  /&gt; &lt;label&gt;Monthly Salary&lt;/label&gt; &lt;input id=em_sal name=em_sal size=10 type=text required  /&gt; &amp;nbsp &amp;nbsp &amp;nbsp &lt;label&gt;Salary Tax&lt;/label&gt; &lt;input id=em_taxds type=text size=10 required /&gt;  ' );

newTextBoxDiv.appendTo("#all_emps");


counter++;
 });

 $("#del_emp").click(function () {


counter--;

    $(".em_area" + counter).remove();

 });
 });
</code></pre>

<p>This is the html code:</p>

<pre><code>&lt;div id="all_emps"&gt;
    &lt;div class="em_area"&gt;
        &lt;label&gt;Employee 1&lt;/label&gt;
        &lt;input type=text required  /&gt;
        &lt;label&gt;Position&lt;/label&gt;
        &lt;input type=text required  /&gt;
        &lt;label&gt;Monthly Salary&lt;/label&gt;
        &lt;input id=em_sal type=text required size=10 onchange="calculateTax(this.value);" /&gt;
        &amp;nbsp &amp;nbsp &amp;nbsp 
        &lt;label&gt;Salary Tax&lt;/label&gt;
        &lt;input id=em_tax name=em_tax type=text required size=10 readonly /&gt;
        &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp
        &lt;a href="#" id="add_emp"&gt;&lt;img src="add.jpg" width="30" height="30"&gt;&lt;/img&gt;&lt;/a&gt;
        &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp
        &lt;a href="#" id="del_emp"&gt;&lt;img src="minus.jpg" width="30" height="30"&gt;&lt;/a&gt;
    &lt;/div&gt;  
&lt;/div&gt;
</code></pre>

<p>This is the tax calculation code in which I have problem:(??????)</p>

<pre><code>function calculateTax(sal)
{
    int salary = parseInt(sal);
    if(salary &lt; 5000)
    {
        document.getElementById("em_tax").value = '0' ;
    }
    else if(salary&gt;5000 || salary=5000)
    {
        var due_tax ;
        due_tax= salary/100;
        due_tax=salary - due_tax;

        document.getElementById("????????").value = due_tax;
    }
}
</code></pre>
