Copy link to clipboard
Copied
I currently have a form with script that I made that if you push a button, a timestamp will show up as mmddHHMMSS. I want to add two letters in front of this time stamp based off another field on my form. For example if they choose Redwood for the Billing Location then I want my time stamp to say RM-mmddHHMMSS. If they choose Montevideo for the Billing Location then I want my time stamp to say MO-mmddHHMMSS. My current script is this the first script I ever wrote and I pieced it together from other examples.
My current script is:
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<AcroForm>
//<ACRO_source>Auto ATOL Click:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Auto ATOL Click:Annot1:MouseUp:Action1 ***********/
var f = this.getField("Auto ATOL");
f.value = util.printd("mmddHHMMss", new Date());
//</ACRO_script>
//</AcroForm>
Copy link to clipboard
Copied
Use this code:
var billingLocation = this.getField("Billing Location").valueAsString;
var prefix = "";
if (billingLocation=="Redwood") prefix = "RM-";
else if (billingLocation=="Montevideo") prefix = "MO-";
// etc.
var f = this.getField("Auto ATOL");
f.value = prefix + util.printd("mmddHHMMss", new Date());
Copy link to clipboard
Copied
This worked perfectly. THANK YOU!!