Copy link to clipboard
Copied
I only have dropdown and list options on my prepare forms toolbar. My dropdown list option does appear to have the same data entering options as the combo box. My searches for the very popular dilemma of auto-populating information based on a dropdown selection have led me to- Combo box (like) or custom javascript (dislike- no experience with it). I am wondering if the icon is just missing from my toolbar or isn't available on my version?
My form is a quote form. Drop-down list of item (product) # and would like the description to auto-populate. And in a perfect world with rainbows and unicorns- populate the price section too. But since I can't even auto-populate 1 additional field, I'm, assuming there is no way I could auto-populate 2 separate fields. I have attached a limited version of my form.
Thank you
Copy link to clipboard
Copied
Hi,
The code to do this is pretty simple ( once you know). The Description field is also formatted as a number so we need to undo that.
Double click the field which in form editing mode ( search tools for "Prepare form")
Select format
Set drop down to "None"
Then edit the "Item1" field and select "Validation" tab and choose to enter a script.
// set default values
var desc = "";
var price = 0;
//if the drop down is this
if (event.value == "501-960817"){
// set the description field to this
desc = "Enter description here";
// set the value to this
price = 10;
// add a new else if block exactly as below and change the "801..." string
} else if (event.value == "801-CD/DVD Recorder"){
desc = "Enter a different description here";
price = 20;
}
// actually set the fields, if you want this for all rows then you will need
// to change Item1-.... to Item2-....
this.getField("Item1-Description").value = desc;
this.getField("Item1-Price").value = price;
Hope this helps
Copy link to clipboard
Copied
For description first return description field format to 'None' and use this at same field custom calculation script:
event.value = this.getField("Item1").value;
For Price as Validation script of "Item1" field use something like this:
if(event.value == "501-960817")
this.getField("Item1-Price").value = 100;
else if(event.value == "801-CD/DVD Recorder")
this.getField("Item1-Price").value = 200;
else if(event.value == "801-Hardware")
this.getField("Item1-Price").value = 300;
Change prices to your actual prices and keep adding 'else if' conditions for other choices.