jquery - Sum checkboxes and select options together -
i hoping add values of multiple select options , checkboxes using jquery have got little stuck. primary issue receive nan combined answer.
i summed dropdowns worked (an example can found @ http://pure.evolvedublin.com/phone) need add checkboxes mix (as seen @ http://pure.evolvedublin.com/broadband-phone).
when click start button on both pages, values become available.
i have tried using solutions found in jquery checkbox , select - sum values , add in var , jquery update initial price on click on checkbox has data-price attribute have not been able them working.
my jsfiddle sample of code here: http://jsfiddle.net/damienoneill2001/77hhd/
i using following code add checkboxes, dont have right:
jquery('input:checkbox').change(function(){ tot=0; jquery('input:checkbox:checked').each(function(){ tot+=parsefloat(jquery(this).val()); }); tot+=parsefloat(document.getelementbyid("broadband_package").value)+parsefloat(document.getelementbyid("irish_mobile_package").value)+parsefloat(document.getelementbyid("intl_landline_package").value)+parsefloat(document.getelementbyid("intl_mob_package").value); jquery('.cost-container').text(tot); jquery('.cost-containerb').val(tot); }); jquery('.broad .irish_mob').change(function(){ jquery('input:checkbox').trigger('change'); });
the values should add total when add button pressed.
can see going wrong?
the following values return undefined
when first check something:
document.getelementbyid("intl_landline_package").value document.getelementbyid("intl_mob_package").value
this because these div
s, not selects
, value
undefined. need loop through checkboxes in these divs , add values individually.
Comments
Post a Comment