multiplication - jQuery multiply only values that are not hidden -
i pondering how add values of inputs specific names via jquery if container div set display block.
something link if ($('#product_' + this.alt).css('display','block')) {
then needs add .each
fetching input this.
$('#product_price_total_pri_' + this.alt).val
any ideas on how put of together?
edit:
obviously should clarify. encased in alt tag of multiple checkboxes , radio buttons id corresponds ids of hidden containers , fields. therefore combination of buttons , checkboxes checked determines hidden areas visible seen here.
function product_analysis_global() { $(':checked').each(function(){ $('#product_' + this.alt).css('display','block'); $('#product_quantity_pri_' + this.alt).val(this.value); var quantity = $('#product_quantity_pri_' + this.alt).val(); var price = $('#product_price_pri_' + this.alt).val(); var duration = $('#product_duration_pri_' + this.alt).val(); var dives = $('#product_dives_pri_' + this.alt).val(); var hire = $('#product_quantity_pri_' + this.alt).val(); $('#product_price_total_pri_' + this.alt).val(price * quantity); $('#product_duration_total_pri_' + this.alt).val(duration * quantity); $('#product_dives_total_pri_' + this.alt).val(dives * quantity); $('#product_hire_total_pri_' + this.alt).val(hire * quantity); });
what need field called 'gt_grand_total' sum of fields area '#product_price_total_pri_' + this.alt).val()'
if panel '#product_' + this.alt
visible.
as per requirement
var arr = $("div[id*='product_']").not(":hidden").map(function(){ return $(this).find("input[id*='product_price_total_pri_']").val(); }).get(); var total = 0; $.each(arr,function() { total += parseint(this); }); alert(total);
or total
var total = eval(arr.join('+')); alert(total);
working example
Comments
Post a Comment