Reg : Additon of two fields in Javascript.
hi,
I have three fileds on the form by name ;
MONDAY_01.
MONDAY_02.
MONDAY_03.
I have another field by name TOTAL.
When the user enters a value in MONDAY_01 field ..
The field TOTAL should be updated.
and
When the user enters a value in MONDAY_02 field ..
The field TOTAL should be updated by adding MONDAY_01 and MONDAY_02 .
and
When the user enters a value in MONDAY_03 field ..
The field TOTAL should be updated by adding MONDAY_01 and MONDAY_02 and MONDAY_03.
Can you please tell me how to do this in JAVA SCRIPT??
Chintan Virani replied
Arjun,
In calculate event of TOTAL field write following code in JavaScript:-
var val1 = 0; var val2 = 0; var val3 = 0; if(MONDAY_01.rawValue != null) { val1 = parseInt(MONDAY_01.rawValue); } if(MONDAY_02.rawValue != null) { val2 = parseInt(MONDAY_02.rawValue); } if(MONDAY_03.rawValue != null) { val3 = parseInt(MONDAY_03.rawValue); } var total = val1 + val2 + val3; if(total > 24) { xfa.host.messageBox("Please enter a value less than 24"); this.rawValue = ""; } else { this.rawValue = total; }
Chintan