JavaScript that calculates specific selections made in multiple dropdowns
Here's the scenario:
A company has 7 representatives (rep) and they need to track how may times that rep was chosen throughout the year. On the form there there is one dropdown that will be repeated 6 times for each month (72 dropdowns per form). Although the dropdowns will have different field names, all will have the same 7 representatives listed. There is a separate text field for each rep to track how may times they were chosen.
I was hoping that a validation script that would be in all of the dropdown fields could include the necessary calculations.
Something like this:
if (event.value=="Rep KD") {
this.getField("QCTeam.KD").value = + "1";
} else this.getField("QCTeam.KD").value = event.value;
if (event.value=="Rep CS") {
this.getField("QCTeam.CS").value = + "1";
} else this.getField("QCTeam.CS").value = event.value;
if (event.value=="Rep SL") {
this.getField("QCTeam.SL").value = + "1";
} else this.getField("QCTeam.SL").value = event.value;
if (event.value=="Rep JC") {
this.getField("QCTeam.JC").value = + "1";
} else this.getField("QCTeam.JC").value = event.value;
if (event.value=="Rep RL") {
this.getField("QCTeam.RL").value = + "1";
} else this.getField("QCTeam.RL").value = event.value;
if (event.value=="Rep CR") {
this.getField("QCTeam.CR").value = + "1";
} else this.getField("QCTeam.CR").value = event.value;
if (event.value=="Rep RM") {
this.getField("QCTeam.RM").value = + "1";
} else this.getField("QCTeam.RM").value = event.value;
I know that the above is not correct (+ before the "1" will not make this calculate) but is basically what I am looking for. Is there a way to write a validation script for the dropdown fields that will add 1 to a text field (and also remove it if a mistake is made and a different rep is chosen)?
If it is not possible to include calculations in a validation script, how do you write a custom calculation scipt that refers to the specific rep chosen (not just the field itself) and then calculate the export value (which would be 1 for all reps) for each rep?
Hope this makes sense. Any help would be appreciated. Thanks for you time.
