I'm trying to incorporate this here with checkboxes on Rails.
My HTML looks like this:
<div>
<input id="reservation_item_ids_" name="reservation[item_ids][]" type="checkbox" value="17">
RCF, 32.0 €/vrk
And the code like this (I'm using jQuery instead of $ to try to avoid conflicts with prototype, which is used by default in Rails 3):
console.log("Initialize!");
jQuery("input[type=checkbox]").click(function() {
console.log("Clicked!");
var total = 0;
jQuery("input[type=checkbox]:checked").each(function() {
total += parseFloat(jQuery(this).val());
});
jQuery("#totalSum").val(total);
});
My console gives me only this:
Initialize!
..regardless of how much I click the checkboxes.. I also tried replacing "input[type=checkbox]" with "#reservation_item_ids" with no luck.
No errors, no clues whatsoever..