Really simple enough JQuery code, can't find mistake...

calculate dynamic totals in a ChronoForms v6 form.

Overview

The custom JavaScript code was placed in the incorrect form section, as the interface differs from CF v5.
Add the JavaScript code using a dedicated JavaScript element in the form designer tab, not the custom code section.

Answered
ChronoForms v6
Cr CrystalFrontier 05 Oct, 2018
Hello everyone,

I'm trying to make text field #total show the calculated values of #debaters*30 and #vvs*25. So, a sum of 55 for one debater + one VVS (train ticket). Two debaters and one VVS would have to show 85 and so on.

Given that I already have a working JQ calculation in a CFv5 form, I wonder if there is a CFv6 issue I should know about when it comes to custom coding? JHint , a code-analysing webpage, can't find a mistake but it's also not fully designed to trace mistakes but just give opinions.

What is yours on these lines of programming?
jQuery(document).ready(function(jQ) {
jQ('#debaters,#vvs,#total').change(fees);

function fees() {

jQ('#total').val(jQ('#debaters').val() * 30 + jQ('#vvs').val() * 25);
}
});
Thank you for any help and best regards,
Christopher
Gr GreyHead 05 Oct, 2018
Hi Christopher,

The JavaScript looks OK. Are you loading this in a JavaScript element in your form?

Do you see any errors if you view the form page using the Web Developer tools in your browser.

Bob
Cr CrystalFrontier 05 Oct, 2018
Hello Bob,

that's the thing.. I can't find a JS element in CF6. I just used 'Custom code'?
Cr CrystalFrontier 05 Oct, 2018
Answer
Ohhhh, gotcha! It's in the designer tab, I only worked inside the setup area. I've added a JS element, and it is working already!

I guess that's different than in previous versions😛

Thanks for the hint!
Christopher
This topic is locked and no more replies can be posted.