Buy Now
Sign in

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

CrystalFrontier , October 05 at 09:13
Answered
C
CrystalFrontier
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
GreyHead
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
CrystalFrontier
Hello Bob,
that's the thing.. I can't find a JS element in CF6. I just used 'Custom code'?
C
CrystalFrontier
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