If/Then Java Script to Populate Fields based on one field's value
- April 23, 2020
- 2 replies
- 1728 views
Hi! I hope someone might help me.
I have this script but it doesn't seem to run. I have no errors popping up.
I'm trying to get my form to pull through the details of the package based on the unit selection, i.e. 50 units is $75 and another field has an overage rate and another field has a billing code. They're all connected, but I want them in individual fields. It's quite possible it's better to use a different formula since ultimately I want to populate multiple fields, but this looked like it should accomplish my goal if I wrote a script for each field I wanted to populate. I'm new to this and got stuck on my first one.
All fields are drop-down menus currently. I'm entering my script in the "Rate" field properties, Actions, Mouse Up, Run a JavaScript.
var Units = this.getField("Units").value;
if (Units=="50") event.value = 75;
else if (Units=="100") event.value = 119;
else if (Units=="150") event.value = 125;
else event.value = "False"
I'd like to have $ signs also, but when it didn't work I took them out.
I set the "Units" field to "Commit selected value immediately" under the options.
I appreciate any advice!
