Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:53:17+00:00 2026-06-13T07:53:17+00:00

I am trying to create a simple html file containing the monthly salary of

  • 0

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!

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

This is the jquery code for adding employee area:

$(document).ready(function(){

var counter = 2;

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


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

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

newTextBoxDiv.appendTo("#all_emps");


counter++;
 });

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


counter--;

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

 });
 });

This is the html code:

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

This is the tax calculation code in which I have problem:(??????)

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

        document.getElementById("????????").value = due_tax;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:53:19+00:00Added an answer on June 13, 2026 at 7:53 am

    The first thing I observed is that you have duplicate Id’s in your HTML.. Make sure the id is unique on the page.. Try Giving them class Names instead..

    <input class=em_sal type=text required size=10 onchange="calculateTax(this.value);" />
     &nbsp &nbsp &nbsp 
    <label>Salary Tax</label>
    <input class=em_tax name=em_tax type=text required size=10 readonly />
    

    Writing Up the change event in JQuery

    $('#all_emps').on('change' , '.em_sal', function() { // Fire the change event
    
        var salary = parseInt(this.value);
        var dueTax = 0;
        if(salary < 5000){  
            // Do Nothing
        }
        else if(salary >= 5000)
        {
            due_tax= salary/100;
            due_tax= salary - due_tax;
        }
        // This will get the corresponding tax input for the employee..
        $(this).closest('div').find('.em_tax').val(due_tax) ;
    });
    

    Check FIDDLE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a simple html file containing the monthly salary of
I am trying to create a simple .bat file that will generate a .html
Im trying to create a simple dll file.Im following the tutorial http://java.sun.com/docs/books/jni/html/start.html when i
I am trying to create simple user registration form. I have an index.html file
So I was trying to follow http://developer.android.com/guide/topics/media/camera.html to create a simple app that captures
I'm trying to create a simple file upload form for my website. I'm using
I'm trying to create an autofill script with AJAX and the Simple HTML DOM
I'm trying to create a simple context menu item to open a file in
I am trying to create a simple HTML Facebook tab for my page, but
I'm trying to create simple script that subscribes a user to a company calendar.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.