I have a combo box that a user can select either "Company" or "Employee". Based upon their selection I would like to sum several text fields(the user enters values in these fields). The result would appear in either the "Company Total" text box or "Employee Total" text box. I have search for a similiar situation but haven't found anything that will work. Any help is greatly appreciated.
// Calculate script for Company field
(function () {
// Get the value of the combo box
var c_val = getField("your_combo").value;
var sum = 0;
if (c_val === "Company") {
// Calculation code goes here, e.g.,
sum += +getField("text1").value;
sum += +getField("text2").value;
sum += +getField("text3").value;
// etc.
// Set this field's value
event.value = sum;
} else {
// Clear field
event.value = "";
}
})();
Replace "your_combo" with the name of the comb box you're using, and adjust the summing code above to suit your needs. The summing code above assumes the fields are numeric.