javascript - My checkbox values are calculating on unchecking instead of checking -


the below code. want calculate value of checked checkbox. want functionality like,when select '#selectall' checkbox, selecting checkboxes , calculating value. in code calculating values on unchecking '#selectall' checkbox . how can fix issue?

$(document).ready(function () {          // select      $('#selecctall').click(function (event) { //on click           if (this.checked) { // check select status              $('.checkbox1').each(function () { //loop through each checkbox                  this.checked = true; //select checkboxes class "checkbox1"                             });          } else {              $('.checkbox1').each(function () { //loop through each checkbox                  this.checked = false; //deselect checkboxes class "checkbox1"                                     });          }      });    });    //addition checked value  $('input').click(function () {      var sum = 0;      $('input[type=checkbox]:checked').each(function () {          sum += number($(this).val());      });      console.log(sum);      $("#sum").html(sum);  });    //popover  $(document).ready(function () {      $('.pop').popover({          content: "other expenses 200 <br> other expenses 200 <br>other expenses 200 <br> ",          html: true,          placement: "right",          trigger: "focus"      });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <tr>          <td align="center">2</td>          <td align="center">2007 / 00006</td>          <td align="center">yousef</td>          <td align="center">gr5 / a</td>          <td align="right">0.000</td>          <td align="right">1000.000              <input type="checkbox" name="checkbox5" id="checkbox5" class="checkbox1" value="1000">          </td>          <td align="right">1000.000              <input type="checkbox" name="checkbox8" id="checkbox8" class="checkbox1" value="1000">          </td>          <td align="right">1000.000              <input type="checkbox" name="checkbox11" id="checkbox11" class="checkbox1" value="1000">          </td>          <td align="right"><strong> 3000.000</strong>            </td>      </tr>      <tr>          <td align="center">3</td>          <td align="center">2012 / 00058</td>          <td align="center">ghalia</td>          <td align="center">kg2 / c</td>          <td align="right">0.000</td>          <td align="right">0700.000              <input type="checkbox" name="checkbox6" id="checkbox6" class="checkbox1" value="700">          </td>          <td align="right">0700.000              <input type="checkbox" name="checkbox9" id="checkbox9" class="checkbox1" value="700">          </td>          <td align="right">0700.000              <input type="checkbox" name="checkbox12" id="checkbox12" class="checkbox1" value="700">          </td>          <td align="right"><strong> 2100.000</strong>            </td>      </tr>      <tr>          <td align="center" class="hide-xs">&nbsp;</td>          <td align="center" class="hide-xs">&nbsp;</td>          <td align="center" class="hide-xs">&nbsp;</td>          <td align="center" class="hide-xs">&nbsp;</td>          <td align="right" class="hide-xs">&nbsp;</td>          <td align="right" class="total"><strong>3100.000                          <input type="checkbox" name="checkbox14" id="checkbox14" class="checkbox1" value="0">                          </strong>            </td>          <td align="right" class="total"><strong>3100.000                          <input type="checkbox" name="checkbox15" id="checkbox15" class="checkbox1" value="0">                          </strong>            </td>          <td align="right" class="total"><strong>3100.000                          <input type="checkbox" name="checkbox16" id="checkbox16" class="checkbox1" value="0">                          </strong>            </td>          <td align="right" class="total"><strong> 9300.000                          <input type="checkbox" name="checkbox13" id="selecctall"  value="0">                          </strong>            </td>      </tr>

i removed :

$(document).ready(function(){     $('.pop').popover({content: "other expenses 200 <br> other expenses 200 <br>other expenses 200 <br> ", html: true, placement: "right", trigger: "focus"});  }); 

and copy/paste code jsfiddle.net

everything seems work... idk problem is... code working on check & uncheck... !

http://jsfiddle.net/sgvwczjq/1/


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -