Emerogork Posted April 19, 2016 Share Posted April 19, 2016 I have been running in circles on this. The web page is to list a few check boxes and when clicked, a sum total should be displayed with each click. [] 5 [] 7 [] 9 When 5 is checked then 5 is displayed. Then when 9 is checked, then 14 is to be displayed. Now if 5 is clicked again then 19 will be displayed. A reset button will clear all checked boxes but I have that coded already. I would rather not use an array but will consider it.This should be only Javascript.and HTML. Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted April 19, 2016 Share Posted April 19, 2016 Are you saying this adds the number regardless of whether the checkbox is checked or not? Link to comment Share on other sites More sharing options...
dsonesuk Posted April 19, 2016 Share Posted April 19, 2016 Might as well use a input type button, since a unchecked/checked checkbox has no significance it seems. Link to comment Share on other sites More sharing options...
kodejuice Posted April 22, 2016 Share Posted April 22, 2016 You dont need arrays for such tasks, try this //using jQuery $(function(){ var total = 0; $("input[type=checkbox]").click(function(){ var disVal = $(this).val(); total += Number(disVal); alert(total); }); $(".resetButton").click(function(){ total = 0; //reset }); }); Link to comment Share on other sites More sharing options...
Ingolme Posted April 23, 2016 Share Posted April 23, 2016 I would first need to fully understand the requirements before providing a solution. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now