I have a PDF form whereas it needs to be able to either be filled out either electronically, or with a good old fashioned pen. As such it includes time calculations with a "Time In" and a "Time Out". For simplification, the form includes the options to select "am" or "pm" accordingly. See form entry sample
So I think I have come up with a cleaver way that if used electronically, I can allow a user to input a time in "h:MM" format and to concat the "am" or "pm" selection putting the result into a hidden field with the "h:MM tt" format and performing my time calculation accordingly. The result in this new hidden field works perfectly for all times except "12:xx". When you choose "pm" it makes the concat result "0:00 am" and if you choose "am" it makes the result "12:00 pm". I cannot figure out how to combat that. Here is the code I am using to create the result in the hidden field:
//format for inputted time
var TimeFormat = "h:MM";
// field names
var str1Field = "TimeIn"
var str2Field = "TimeInTT"
// get field values
var str1 = this.getField(str1Field).value;
var str2 = this.getField(str2Field).value;
// concat strings if there is data
if(str1 != "" && str2 != ""){
var res = (TimeFormat, str1) + " " + str2;
event.value = res;
}
"TimeIn" is a time field "h:MM" and "TimeIn TT" is the "am" or "pm". Any help with this is greatly appreciated. Maybe there is a better way to do it? Thank you.