diff -r f0ec83e1e01f -r dad62ec9af18 www/js/inv_fermentables.js --- a/www/js/inv_fermentables.js Wed Jan 23 22:36:31 2019 +0100 +++ b/www/js/inv_fermentables.js Wed Jan 23 22:53:24 2019 +0100 @@ -43,6 +43,14 @@ $(document).ready(function () { + + var dataRecord = {}; + + function calcTotal(cost, inventory) { + + $('#totval').val(cost * inventory); + } + var url = "includes/db_inventory_fermentables.php"; // prepare the data var source = { @@ -178,6 +186,9 @@ $("#production_date").jqxDateTimeInput( Dateopts ); $("#cost").jqxNumberInput( Spin2dec1 ); $("#tht_date").jqxDateTimeInput( Dateopts ); + $("#totval").jqxNumberInput( Spin2dec1 ); + $("#totval").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); + var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; // initialize jqxGrid @@ -263,7 +274,7 @@ editrow = row; $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); // get the clicked row's data and initialize the input fields. - var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); + dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); $("#type").val(dataRecord.type); $("#yield").val(dataRecord.yield); @@ -288,12 +299,23 @@ $("#cost").val(dataRecord.cost); $("#production_date").val(dataRecord.production_date); $("#tht_date").val(dataRecord.tht_date); + calcTotal(dataRecord.cost, dataRecord.inventory); // show the popup window. $("#popupWindow").jqxWindow('open'); } } ] }); + + $("#cost").on('change', function (event) { + dataRecord.cost = parseFloat(event.args.value); + calcTotal(dataRecord.cost, dataRecord.inventory); + }); + $("#inventory").on('change', function (event) { + dataRecord.inventory = parseFloat(event.args.value); + calcTotal(dataRecord.cost, dataRecord.inventory); + }); + // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ width: 1050,