Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
How To Make Total For Every Column By Using Jquery
ahmed salah
8y
205
1
Reply
Name salary Bonus Deduction total
mickel 500 600 300 800
adil 600 600 600 600
total 1100 1200 900 1400
how to make total for every column meaning how to do total found last line for all column
total 1100 1200 900 1400
my code as following
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width"
/>
<title>Index</title>
<script src=
"~/Scripts/jquery-1.10.2.js"
></script>
<script>
$(function () {
$(
"#btn"
).click(function () {
var x = $(
"#txt1"
).val();
var y = $(
"#txt2"
).val();
var z = $(
"#txt3"
).val();
var M = $(
"#txt4"
).val();
var L = parseInt(y) + parseInt(z) - parseInt(M);
$(
"#tb"
).append(
"<tr> <td>"
+ x +
"</td> <td>"
+ y +
"</td> <td>"
+ z +
"<td>"
+ M +
"</td><td>"
+ L +
"</td></tr>"
);
});
$(
"#tb"
).on(
"click"
,
"tr"
, function () {
$(
this
).find(
"td"
).slice(0, 4).prop(
"contenteditable"
,
true
);
});
});
</script>
</head>
<body>
<div>
Name<input type=
"text"
id=
"txt1"
/><br />
Salary<input type=
"text"
id=
"txt2"
/><br />
Bonus<input type=
"text"
id=
"txt3"
/><br />
Deduction<input type=
"text"
id=
"txt4"
/><br />
<input type=
"button"
value=
"add"
id=
"btn"
/>
<table>
<thead>
<tr>
<td>
Name
</td>
<td>
Salary
</td>
<td>
Bonus
</td>
<td>
Deduction
</td>
<td>
total
</td>
</tr>
</thead>
<tbody id=
"tb"
class
=
"tb1"
></tbody>
</table>
</div>
</body>
</html>
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Change Cell Content Salary Or Bonus change total same time
How to load data on drop down scroll load ?? (ASP.NET MVC)