HELP! I'm new to javascipting and need to create a form for work:
We need to charge boaters a fee depending on the number of days staying (docking) and the boats berthage (length).
I have a field that creates the total days from two drop down calendars currently. I also have have a field with a drop down selection of the boats length.
However, I have no idea how to combined the two though?
Here's what I need to calculate/charge from the two fields:
If boat is staying less then 30 days I need to charge $20/day
If boat is <18m AND is staying longer then 30 days they are charged $260/month
If boat is between 18-20m AND they are staying longer then 30 days charged $280/month
Please help :S
Are you able to share the document via a sharing platform, so that we can provide help based on how you created your form, as there are many ways to achieve this?
Would this help Malcolm?
Heres the charges I need to charge based on the boat length (berthage)
You can use this code as the custom calculation script of your field (you'll probably need to adjust the field names in the first two lines, to match the actual ones in your file):
var stayDuration = Number(this.getField("StayDuration").valueAsString);
var boatLength = Number(this.getField("BoatLength").valueAsString);
if (stayDuration==0 || boatLength==0) event.value = "";
else if (stayDuration<30) event.value = "$20/day";
if (boatLength<18) event.value = "$260/month";
else event.value = "$280/month";
I get an error when I try and create this scripting?
In the future post your code as text, not an image.
I can see an error in the screenshot, though. You're missing an operator between