Script for text field to populate miles based on two drop down selections
- May 31, 2024
- 3 replies
- 1941 views
I have a drop down field named "Dropdown 1.0" for the beginning location and a second drop down field
named "Dropdown 1.2" for the ending location. What script would I use in the text field named "MilesRow1" to calculate the miles between the two locations Dropdown 1.0 and Dropdown 1.2.
There will be the same 20 sites to choose from in all the drop downs. I've attached the mileage sheet that shows the mileage between each of the 20 sites. Would I need to create a script like below for each MilesRow field or is there a better way. Is the below script even correct?
I don't have any JavaScript knowldege so as much detail of the script would be very helpful.
var MilesRow1 = this.getField("Dropdown1.0").valueAsString;
if (Dropdown1.0=="MERC") and (Dropdown1.2=="Special Services (SSC)") event.value = "1.4";
else if (Dropwdown1.0=="MERC") and (Dropdown1.2=="Valley (VE) 110") event.value = "5.5";
else if
I previously did one drop down field that combined the beginning and ending location but it created too many options in one drop down even though it was easier to create an Extract Value and custom calculation script.
Thank you for your valuable time and help
