This is the code ive put together so far. I am running into the error that event.value is NOT a function.
i would appreciate any help to correct the code. This code is for an editable pdf that is in a flowed container. The table has new instance added with the click of a button so the code copies down with each new addition to the table.
Code is Below:
if (this.getField("timeout").valueAsString.length === 0 || this.getField("timein").valueAsString.length === 0) {
event.value = "0";
}
else{
var timefinished = this.getField("timeout").valueAsString.length;
var timestarted = this.getField("timein").valueAsString.length;
var difflnMilliSeconds = Math.abs(timefinished - timestarted )/1000;
// calculate hours
var hours = Math.floor(difflnMilliSeconds / 3600) % 24;
difflnMilliSeconds = hours *3600;
// calculate minutes
var minutes = Math.floor(difflnMilliSeconds / 60) % 60;
difflnMilliSeconds = minutes * 60;
// set field value to the difference
event.value = hours + ":" + minutes;
}
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @dgarner2110
@Saravanan_Dharmaraj meant to ask question in PDF community to get better/faster response to your question
However, i am not an expert in PDF but the javascript code to find difference between two time is
// Get the values of the two date fields
var date1 = this.getField("dateField1").value;
var date2 = this.getField("dateField2").value;
// Calculate the difference in hours between the two dates
var diffInMilliseconds = Math.abs(date2.getTime() - date1.getTime());
var diffInHours = Math.floor(diffInMilliseconds / (1000 * 60 * 60));
// Set the value of the current field to the calculated difference in hours
event.value = diffInHours;
@arunpatidar do you have any experience with this?
@dgarner2110 Posting the question in form specific forum would help in getting solution
Ok Thanks
Hi @dgarner2110
@Saravanan_Dharmaraj meant to ask question in PDF community to get better/faster response to your question
However, i am not an expert in PDF but the javascript code to find difference between two time is
// Get the values of the two date fields
var date1 = this.getField("dateField1").value;
var date2 = this.getField("dateField2").value;
// Calculate the difference in hours between the two dates
var diffInMilliseconds = Math.abs(date2.getTime() - date1.getTime());
var diffInHours = Math.floor(diffInMilliseconds / (1000 * 60 * 60));
// Set the value of the current field to the calculated difference in hours
event.value = diffInHours;
The code you have shown doesn't work. the code I'm trying to figure out is for a LiveCycle form.
Hi @dgarner2110
That was. a sample code, I am not an LiveCycle developer, so can't help with the code but As i suggest to move this thread to dedicated LiveCycle forum.
Hi,
It looks like the issue with your code is that you're trying to call the value() function on the event object, which isn't a valid function.
In JavaScript, the event object doesn't have a value() function, so you'll need to use a different approach to set the field value. Instead, you can use the value property of the field object to set its value.
Regards,
Manvi Sharma
I have been playing with this code:
However it returns 0 like it should, but the time calculation doesn't seem to work.
if (timein.rawValue == 0 || timein.rawValue == null || timeout.rawValue == 0 || timeout.rawValue == null){
this.rawValue=0;
}
else{
var timefinished = (timeout.rawValue);
var timestarted = (timein.rawValue);
var difflnMilliSeconds = Math.abs(timefinished - timestarted )/1000;
// calculate hours
var hours = Math.floor(difflnMilliSeconds / 3600) % 24;
difflnMilliSeconds = hours *3600;
// calculate minutes
var minutes = Math.floor(difflnMilliSeconds / 60) % 60;
difflnMilliSeconds = minutes * 60;
// set field value to the difference
this.rawValue = hours + "." + minutes;
}
Views
Likes
Replies