-
bescott53
Post
by bescott53 » 2020-02-06 19:16
Hi board, I have looked at the course and came up with this for calculation a total
Code: Select all
$j('#TravelAndSubsitence, #PoCost, #ForecastFees').change(function(){
var TravelAndSubsitence = parseFloat($j('#TravelAndSubsitence').val() || 0;
var PoCost = parseFloat($j('#PoCost').val() || 0;
var ForecastFees = parseFloat($j('#ForecastFees').val() || 0;
var training_expense_cost = (TravelAndSubsitence + PoCost + ForecastFees);
$j('#training_expense_cost').val(training_expense_cost);
});
but its not working, any ideas. i am putting this inside the magic hook file
-
jsetzer
- AppGini Super Hero
- Posts: 1814
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2020-02-08 00:45
Hi,
what exactly is not working? Are there any console errors? Are you sure the event fires?
I highly recommend adding some logging and checking the values by using console.log(...) a lot like this:
Code: Select all
$j('#TravelAndSubsitence, #PoCost, #ForecastFees').change(function(){
console.log("field change event handler");
var TravelAndSubsitence = parseFloat($j('#TravelAndSubsitence').val() || 0;
console.log('TravelAndSubsitence:' + TravelAndSubsitence);
var PoCost = parseFloat($j('#PoCost').val() || 0;
console.log('PoCost:' + PoCost);
var ForecastFees = parseFloat($j('#ForecastFees').val() || 0;
console.log('ForecastFees:' + ForecastFees);
var training_expense_cost = (TravelAndSubsitence + PoCost + ForecastFees);
console.log('training_expense_cost:' + training_expense_cost);
console.log('before:' + $j('#training_expense_cost').val());
$j('#training_expense_cost').val(training_expense_cost);
console.log('after:' + $j('#training_expense_cost').val());
console.log('/field change');
});
Then watch the console output for any errors or warnings and for the logged values.
Hope this helps!
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools