Skip to main content
Participant
October 12, 2021
Question

Autofill based on the values in two other fields

  • October 12, 2021
  • 1 reply
  • 737 views

I have an in-county travel form and I want the distance between locations to autofill based on the dropdown input of the starting and ending location.For example, if I start at BHS and end at BES, I want the field to automatically fill with 1.3 miles.  The starting and ending locations are drop downs. Is there a standard if then script, like if "this" AND "this" then "that"?

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
October 13, 2021

In dropdown fields, set distance as export value of each choice, then in 'Miles' field calculate difference something like this:

Example for first row:

var a = Number(this.getField("startrow1").value);
var b = Number(this.getField("endrow1").value);
var x = "";
if(a>b)x = a-b;
else if(a<b)x = b-a;
event.value = x;

 

In dropdown fields -> options tab tick 'Commit selected value immediatelly'.

 

Participant
October 13, 2021
How do I put an export value for the dropdown for endrow? The startrow
field is going to always be zero because you will always start at zero
miles, but the end distance will depend on both where you started
(startrow) from and your destination (endrow)
Tiffany Nichols
Instructional Technology Specialist
Calhoun County School District
850-674-8734 ext 243
http://calhounflschools.org/help-desk
“Technology will never replace great teachers, but in the hands of great
teachers, it’s transformational.” – George Couros