Some extra information to go on, this is the line where the error is occuring:
`
var fld_8054423_1 = parseFloat( $(‘[data-field=”fld_8054423_1″]’).is(‘:checkbox’) ? checked_total_fld_2628740_1($(‘[data-field=”fld_8054423_1″]:checked’)) : $(‘[data-field=”fld_8054423_1″]’).is(‘:radio’) ? $(‘[data-field=”fld_8054423_1″]:checked’).val() : $(‘[data-field=”fld_8054423_1″]’).val() ) || 0 , fld_6702947_1 = parseFloat( $(‘[data-field=”fld_6702947_1″]’).is(‘:checkbox’) ? checked_total_fld_2628740_1($(‘[data-field=”fld_6702947_1″]:checked’)) : $(‘[data-field=”fld_6702947_1″]’).is(‘:radio’) ? $(‘[data-field=”fld_6702947_1″]:checked’).val() : $(‘[data-field=”fld_6702947_1″]’).val() ) || 0 ,
total = (fld_8054423_1_1*fld_6702947_1_1);
‘
Notice that the field is referred as fld_8054423_1 when it is referenced in the parseFloat function but when utilised in the total section at the end it is trying to find fld_8054423_1_1 which doesn’t exist.
This is a very simple form with one slider, a drop down select and a hidden field with a total that works on the two elements.
Cheers David.
Hi David,
Thought it may help to have the whole Javascript function that is failing to see what is going on:
<script type="text/javascript">
jQuery(function($){
function checked_total_fld_2628740_1(items){
var sum = 0;
items.each(function(k,v){
sum += parseFloat($(v).val());
})
return sum;
}
function docalc_fld_2628740_1(){
var fld_8054423_1 = parseFloat( $('[data-field="fld_8054423_1"]').is(':checkbox') ? checked_total_fld_2628740_1($('[data-field="fld_8054423_1"]:checked')) : $('[data-field="fld_8054423_1"]').is(':radio') ? $('[data-field="fld_8054423_1"]:checked').val() : $('[data-field="fld_8054423_1"]').val() ) || 0 , fld_6702947_1 = parseFloat( $('[data-field="fld_6702947_1"]').is(':checkbox') ? checked_total_fld_2628740_1($('[data-field="fld_6702947_1"]:checked')) : $('[data-field="fld_6702947_1"]').is(':radio') ? $('[data-field="fld_6702947_1"]:checked').val() : $('[data-field="fld_6702947_1"]').val() ) || 0 ,
total = (fld_8054423_1_1*fld_6702947_1_1);
total = total.toFixed(2);
$('#fld_2628740_1').html( total );
$('[data-field="fld_2628740_1"]').val( total ).trigger('change');
}
$('body').on('change keyup cf.remove cf.add', '[data-field="fld_8054423_1"],[data-field="fld_6702947_1"],#conditional_fld_8054423_1,#conditional_fld_6702947_1', function(e){
docalc_fld_2628740_1();
});
docalc_fld_2628740_1();
});
</script>
Thanks for that – I’ll take a look in a moment.
Cheers David, ignore my title for this thread as the example I have given doesn’t use hidden elements.
All I have is a slider, a drop down box and a total field, the total should be a multiplication of the two but cannot get it to work.
One last thing, the error above is based on me doing a manual formula. If I deselect the manual formula and use your point and click selection of the two fields it then works as expected.
OH wow- thanks that explains a lot.
I’ll make a fix and sort it out. thanks.
Do you think there is any possibility that you may be able to get the fix out before Sunday David?
I have fixed it on the GitHub version which you can download here- https://github.com/Desertsnowman/Caldera-Forms
I have a few more little issue I need to solve before I release a full update here. Not sure it will be before sunday.