I am unable to calculate using class? I am trying to access dynamic id using class
@foreach($room_types as $room_type)
{!! Form::text(‘cost’, null, [‘class’ => ‘form-control cost-‘.$room_type->id, ‘placeholder’ => ‘Enter Cost’]) !!}
{!! $errors->first(‘cost’,’:message’) !!}
@endforeach
and this is the script
$(‘.cost{{ $room_type->id }}’).keyup(function() {
var roomTypeId = $(this).data('room-type-id');
var cost = parseFloat($('.cost').val());
var profit = parseFloat($('.profit').val());
var tax_percentage = parseFloat($('.tax-percentage').val());
checkNum('.cost');
total_cost = calculate_total_cost(cost, profit, tax_percentage);
$('.total-cost').val(total_cost);
});
New contributor
Abhijeet Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.