JavaScript being used for a cash drawer/register type form in the JavaScript OnLoad event of add/edit pages.
User input fields are cs1-7, css12, csss14-15
Hope this helps others and works great. Can be modified to fit other needs and I'm sure written better :-) The only problem has been a decimal problem when adding odd numbers. In the subtotal for example looks like 111.000002. Anybody have any ideas?
Thanks in advance for any ideas.
var cs1 = Runner.getControl(pageid, '100s');
var cs2 = Runner.getControl(pageid, '50s');
var cs3 = Runner.getControl(pageid, '20s');
var cs4 = Runner.getControl(pageid, '10s');
var cs5 = Runner.getControl(pageid, '5s');
var cs6 = Runner.getControl(pageid, '1s');
var cs7 = Runner.getControl(pageid, 'coin');
var css11 = Runner.getControl(pageid, 'totalcash');
var css12 = Runner.getControl(pageid, 'lessbank');
var csss13 = Runner.getControl(pageid, 'cashtotal');
var csss14 = Runner.getControl(pageid, 'creditcards');
var csss15 = Runner.getControl(pageid, 'credittips');
var cstotal = Runner.getControl(pageid, 'totalcash');
var csstotal = Runner.getControl(pageid, 'cashtotal');
var cssstotal = Runner.getControl(pageid, 'grandtotal');
function func() {
cstotal.setValue(Number(cs1.getValue()) + Number(cs2.getValue()) + Number(cs3.getValue()) + Number(cs4.getValue()) + Number
(cs5.getValue()) + Number(cs6.getValue()) + Number(cs7.getValue()));
csstotal.setValue(Number(css11.getValue()) - Number(css12.getValue()));
cssstotal.setValue(Number(csss13.getValue()) + Number(csss14.getValue()) + Number(csss15.getValue()));
};
cs1.on('keyup', func);
cs2.on('keyup', func);
cs3.on('keyup', func);
cs4.on('keyup', func);
cs5.on('keyup', func);
cs6.on('keyup', func);
cs7.on('keyup', func);
css11.on('keyup', func);
css12.on('keyup', func);
csss13.on('keyup', func);
csss14.on('keyup', func);
csss15.on('keyup', func);