$("tbody input[name='rooms_to_book']").on('change',function(){
    var current_row = $(this).closest("tr");
    var current_checkbox = current_row.find("input[name=checkbox]");
    if(current_checkbox.checked) {
        var price_per_night = parseFloat(current_row.find("td[name=price]").text().replace('$',''));
        var rooms_to_book = parseInt(current_row.find("input[name=rooms_to_book]").val());
        rooms_to_book = rooms_to_book ? rooms_to_book : 0;
        total_price = price_per_night * rooms_to_book;
    }else{
        total_price = 0;
    }
    current_row.find("td[name=total_price]").text('$'+ total_price);
});
The current_checkbox.checked always returns false, the html is correct.
jQuery objects do not have a checked property. Replace
current_checkbox.checked
with
current_checkbox.prop('checked')
http://api.jquery.com/prop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With