Field values not updating immediately, custom calculation script.
I have two fields from which I am trying capture the (numeric) values from. They are named BS BEFORE.x and CARBS.x, with x being a value between 0 and 5, depending upon which record number of the current event. In this code snippet I am merely placing the values into a text field named TEST just for display purposes. Ultimately, these values will be used to calculate a recommend dose of fast acting insulin. The problem is, TEXT.value only updates with the value entered into BS BEFORE.x and CARBS.x AFTER the next entry is made.
HERE IS THE CODE:
// THIS IS A TEST FIELD TO SHOW RESULTS
var TEST = this.getField("TEST"); TEST.value = "";
// CAPTURE RECORD NUMBER FROM THE FIELD NAME AND TRIM BLANKS
var RecordNo = event.target.name.substring(event.target.name.length-1);
RecordNo = RecordNo.trim(RecordNo);
// GET THE VALUE OF CURRENT BS AND CARB FIELDS
var myBS= this.getField("BS BEFORE." + RecordNo);
var myCarbs = this.getField("CARBS." + RecordNo);
// SHOW TEST VALUES
TEST.value = myBS.value + " : " + myCarbs.value;
Incidentally, is there a way to do this using calculation without calculating everything in the form?
Message was edited by: Malcolm Thomson - Removing unnecessary caps in title.
