How to Add values from checkboxes
Hello Everyone,
I am trying to sum the values from the selected checkboxes ... But so far what i am getting is like 2,3...what i want is 5....Can anybody help me out to get this logic please. Thanks!!!!
- <html>
- <head>
- <title>jQuery With Example</title>
- <script src="http://code.jquery.com/jquery-1.9.1.js"
- type="text/javascript"></script>
- <script type="text/javascript">
- $(function () {
- $('.btnGetSelectedValue').click( function(){
- var chkId = '';
- $('.chkNumber:checked').each(function() {
- chkId += $(this).val() + "+";
- });
- /* chkId = chkId.slice(0,-1); */
- alert(chkId);
- });
-
- });
- </script>
- </head>
- <body>
- <div>
- <input type="checkbox" class="chkNumber" value="1" />One<br />
- <input type="checkbox" class="chkNumber" value="2" />Two<br />
- <input type="checkbox" class="chkNumber" value="3" />Three<br />
- <input type="checkbox" class="chkNumber" value="4" />Four<br />
- <input type="checkbox" class="chkNumber" value="5" />Five<br /><br
- />
- </div>
- <button type="button"
- class="btnGetSelectedValue">GetSelectedValue</button><br />
- </body>
- </html>