Populate form field name from text box
Hi,
I've looked and haven't found the easiest path to making my text field auto populate initials for a checklist. I have about 185 fields over 3 columns and know there must be an easier way than adding this script to each form field individually.
// check form field, if blank add initials, if initials make N/A, if N/A make blank
var initialsField= this.getField("RIC2").valueAsString;
if(initialsField==""){
this.getField("RIC2").value=this.getField("RICInitials").value;
}
else if (initialsField==this.getField("RICInitials").value){
this.getField("RIC2").value= "N/A";
}
else if (initialsField=="N/A"){
this.getField("RIC2").value= "";
}Initially, I was going to paste that in the action tab with the on focus trigger and change the form field each time but I thought programmers are way smarter than that but I can't figure out what to do next.
I thought I could make a function in the main javascript part, I think that is called document level. Then I saw something about event.target.value but can't figure out how to make either work.
If you don't mind, all I want to change above is instead of putting the field name, some snippet of code that says "for your field name" or "take action in your field" so I dont have to change it to say "field1", "field2", "field3", etc. With that I can select all of the fields applicable and add all of the same action on focus run a javascripts at the same time.
Thank you for any guidance.
