Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //div:ar
- <div id="halvtot"></div>
- <div id="heltot"></div>
- //tipskoll.js
- $(document).ready(function () {
- $("#halvtot").text(getHalv());
- $("#heltot").text(getHel());
- $("input[id*='ctl']").click(function () {
- CalculateGarderingar(this);
- });
- });
- var hel = 1;
- var halv = 7;
- function AddHel() {
- hel = hel - 1;
- }
- function AddHalv() {
- halv = halv - 1;
- }
- function RemoveHel() {
- hel = hel + 1;
- }
- function RemoveHalv() {
- halv = halv + 1;
- }
- function getHel() {
- return hel;
- }
- function getHalv() {
- return halv;
- }
- function getHelPrint() {
- return ((getHel() < 0) ? 0 : getHel());
- }
- function getHalvPrint() {
- return ((getHalv() < 0) ? 0 : getHalv());
- }
- function CalculateGarderingar(obj) {
- var action = $(obj).attr('checked');
- var objs = $(obj).closest("tr").find("input:checkbox");
- var tot = 0;
- $(objs).each(function () {
- if($(this).attr('checked'))
- tot++;
- });
- if (tot == 3) {
- AddHel();
- RemoveHalv();
- }
- if (tot == 2 && action == true) {
- AddHalv();
- }
- if (tot == 2 && action == false) {
- AddHalv();
- RemoveHel();
- }
- if (tot == 1 && action == false) {
- RemoveHalv();
- }
- //reload garderingar
- $("#halvtot").text(getHalvPrint());
- $("#heltot").text(getHelPrint());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement