Copy link to clipboard
Copied
Hi all, I need help, I have created a form that has value fields, and I'm looking for a script to calculate the total of these fields, and IF the sum value of these fields combined is greater than the value of 40 I want the total to display 40, if it is less than 40 I want it to calculate and display the fields totals,
I know in excel calculations is like this is IF(SUM(e1:e17)>40,40,SUM(e1:e17))
I just need a javascript to do the same if it is possible
The fields I need the calculation is "EF1" to "EF16" plus "ExhibitFee" to be placed in a field named "SubTotal"
Cheers Geoff
Hi again,
I found a solution to my question, I created a hidden field with the totals of the required fields, then thanks to youtube I found a video, this is the script I have found that worked, so happy I did my very first javascript :)
var sub = this.getField("HiddenSubTotal").value;
if(sub>40){event.value = "40"}
else {event.value = sub};
Copy link to clipboard
Copied
Hi again,
I found a solution to my question, I created a hidden field with the totals of the required fields, then thanks to youtube I found a video, this is the script I have found that worked, so happy I did my very first javascript :)
var sub = this.getField("HiddenSubTotal").value;
if(sub>40){event.value = "40"}
else {event.value = sub};
Copy link to clipboard
Copied
Thank you for sharing that solution.
Copy link to clipboard
Copied
There is no need for hidden field, you can just use sum(+) in "SubTotal" field and place this script under 'Validate' tab:
if(event.value > 40)event.value = 40;
Copy link to clipboard
Copied
With little to no experience with Java, I just used what I found this morning unfortunately my document has to go public tonight within my community club, I have to really look into Javascript language, thank you for your suggestion