Dear all
In an attempt to re-create a CF4 form into either CF5 or 6, I have tried as much as I can to mirror a key custom JS that had been established years ago through this very helpful forum. In short, it's a simple in-form calculation with one complex element, culminating in showing the calculated result in a field ID 'fees_acc'.
It begins simple enough: 'debaters', 'judges', 'observers' are three client groups with three different fee values. Number of clients per group X fee = total fee. Add onto this 'extra_nights' and 'singles' (for single rooms), you receive a total fee_acc (includes accommodation).
However, there are two key field values when determining a discount: 'teams' and 'judges'. Should one team bring one judge, no discount applies. Should an 'n' number of teams bring +1 judge, a discount of € 30 applies to all judges, in the case of n+2 (or more), the discount is € 50 per judge (so, we're incentivising teams to bring judges).
The JS script co-operatively compiled through this forum back then (CF4) was this:
Now in CF 5 or 6 (I am currently working parallel on both, but prefer CF5 bc of Google Spreadsheet item), nothing happens, and it seems as if some striking change has occured in the way JS is being used.
I assume, the change is not significant, but not being a coder myself (which is why I use CF in the first place), I do not see what needs to be done. I have tried adopting principles that may apply to CF 5 (replacing $ with jQuery etc...) but I can't create the same result, or any result for that matter.
Any help is much appreciated!
Thanks and have a nice weekend,
Christopher
In an attempt to re-create a CF4 form into either CF5 or 6, I have tried as much as I can to mirror a key custom JS that had been established years ago through this very helpful forum. In short, it's a simple in-form calculation with one complex element, culminating in showing the calculated result in a field ID 'fees_acc'.
It begins simple enough: 'debaters', 'judges', 'observers' are three client groups with three different fee values. Number of clients per group X fee = total fee. Add onto this 'extra_nights' and 'singles' (for single rooms), you receive a total fee_acc (includes accommodation).
However, there are two key field values when determining a discount: 'teams' and 'judges'. Should one team bring one judge, no discount applies. Should an 'n' number of teams bring +1 judge, a discount of € 30 applies to all judges, in the case of n+2 (or more), the discount is € 50 per judge (so, we're incentivising teams to bring judges).
The JS script co-operatively compiled through this forum back then (CF4) was this:
window.addEvent('domready', function() {...and it worked like a charm as a JS script in the 'Events' section (see here).
$('debaters').addEvent('change', rekenen1);
$('judges').addEvent('change', rekenen1);
$('observers').addEvent('change', rekenen1);
$('singles').addEvent('change', rekenen1);
$('extra_nights').addEvent('change', rekenen1);
});
function rekenen1(){
var num_teams = $('teams').value;
var num_judges = $('judges').value;
var num_extras = num_judges - num_teams;
var discount = 0;
if(num_extras > 0) {
discount = 30;
if(num_extras > 1) {
discount = 50;
}
}
$('fees_acc').value = $('debaters').value * 220 + $('judges').value * (220 - discount) + $('observers').value * 350 + $('singles').value * 90 + $('extra_nights').value * 30;
}
Now in CF 5 or 6 (I am currently working parallel on both, but prefer CF5 bc of Google Spreadsheet item), nothing happens, and it seems as if some striking change has occured in the way JS is being used.
I assume, the change is not significant, but not being a coder myself (which is why I use CF in the first place), I do not see what needs to be done. I have tried adopting principles that may apply to CF 5 (replacing $ with jQuery etc...) but I can't create the same result, or any result for that matter.
Any help is much appreciated!
Thanks and have a nice weekend,
Christopher