I have table which contain following data structure:
ID | payroll_cat_name | payroll_cat_code | category_type | amount |
---|---|---|---|---|
1 | Provident Fund | PF | dedution | 1000 |
2 | Basic Pay | BC | earning | 35000 |
3 | Travelling | TA | earning | 6500 |
4 | Home Allowance | HM | earning | 12000 |
5 | Tax | TX | dedution | 500 |
My Answer:
To calculate the value of the checked box, you can use JavaScript to loop through all the checkboxes and calculate the total amount based on the checked checkboxes.
Here is an example code snippet to achieve this:
html
Calculate Total Amount
ID
payroll_cat_name
payroll_cat_code
category_type
amount
Check
1
Provident Fund
PF
dedution
1000
2
Basic Pay
BC
earning
35000
3
Travelling
TA
earning
6500
4
Home Allowance
HM
earning
12000
5
Tax
TX
dedution
500
Total Amount: 0
In this code snippet, we have created a table with checkboxes for each row. When the "Calculate Total" button is clicked, the `calculateTotal` function is called which loops through all the checkboxes and adds up the values of the checked checkboxes to calculate the total amount. The total amount is then displayed in the `` element with the id "totalAmount".
Rate this post
5 of 5 based on 1302 votesComments