I started using javascript extensively in my applications when the interactive grid first came out, but I am far from being expert at it.
I'm using an Interactive Grid master-detail setup and at one point I need to do some calculations based on 4 columns in the detail grid - unit_price, operator ( * or /), quantity and markup (a percentage). When the grid is saved, the calculations are recalculated on the server side. The user can change any of the 4 items and can save at any time. When they save, the total of all the detail items is placed into the selected record in the master grid.
The user may also go to a popup modal dialog which returns the unit_price based on some calculations they do there. This is all working fine, except for one thing - in the javascript DA's which do the calculations, the item values returned by getSelectedRecords() is not giving me the current field values as changed by the user, but is giving me the previous values. For example, if the quantity is set to 10, and the user changes it to 20, the DA which does the calculation still thinks the value is 10.
I can mostly get around this by using "this.triggeringElement.value" in a DA on each of the fields to get the current value when the field is changed, passing this and the name of the element to the calculation function:
var te = "unitCost";
var teVal = this.triggeringElement.value;
calculateCosts( te, teVal );
This does give me the current value of the field as changed, but what I really need is to reliably retrieve the current value of all of the fields at one time, whether changed by the user or not. I'm sure there must be a simple way, but I'm not getting it.
Thanks!