Sum of checkbox values

Asked

Viewed 60 times

0

I have the following script

	$(document).ready(function() {

		$(".soma").bind("blur change check", function() {
		total = 0;

			$("input[type='checkbox']:checked").each(function() {
			total+=parseFloat($(this).val());
			});

			$(".soma").each(function() {
			if( $(this).attr('type')=='text' || $(this).is('select') ) {
			total+=parseFloat($(this).val());
			}
			});

			$("#input_resultado").val(total.toFixed(2));
			$("#resultado").html(total.toFixed(2));
		}
	});

It takes the value of the checkbox makes a summation and saves within a variable.

That code is working, but now it’s stopped.

Algem could help me.

  • Changes the } who stands alone at the end to }); to properly close the $(".soma").bind(

  • Sergio, I did it but it still does not result in the variable

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.