Copy link to clipboard
Copied
I have no java script or programming experience.
Trying to have a text field pre-fill based on the selection of any multiple dropdown boxes. Trying to auto fill the authority name that needs to sign when one or more dropdown has the appropriate selection. I can get it down with just one dropdown field but trying to make the pre fill appear if the selection appears in the other drop down.
var selectedPackage = this.getField ("Dropdown5.0").value;
if (selectedPackage=="K - RST") event.value= "COL, Chief of Staff";
// etc
else event.value = "";
I tried to repeat the script for each dropdown box name but either it just works for the first one or all 5 of the dropdown needs to be selected to "K"
The problem is with your last line of code. Since you didn't use if-else if-else it only applies to your last if-statement, which means that most of the time the value will probably be empty (unless the last drop-down happens to be "K - RST after or on IDT").
There are also several syntax errors in your code and it's quite of cumbersome. I would do it like this:
...event.value = "";
var selectedPackageFields = this.getField("Dropdown5").getArray();
for (var i in selectedPackageFields) {
if (selected
Copy link to clipboard
Copied
Is this code in the calculation script for the text field? If it is, you are on the right track. What is the complete code you are using for handling the other dropdowns?
Copy link to clipboard
Copied
Sorry was being a bit lazy. I couldn't copy and paste the code so I was typing out everything
var selectedPackage = this.getField ("Dropdown5.0").value;
if (selectedPackage=="K - RST after or on IDT") event.value="COL, Chief of Staff";
var selectedPackage = this.getField (Dropdown5.1").value;
if (selectedPackage=="K - RST after or on IDT") event.value="COL, Chief of Staff";
var (selectedPackage = this.getField (Dropdown5.2").value;
if (selectedPackage=="K - RST after or on IDT") event.value="COL, Chief of Staff";
var (selectedPackage = this.getField (Dropdown5.3").value;
if (selectedPackage=="K - RST after or on IDT") event.value="COL, Chief of Staff";
// etc.
else event.value = "";
Copy link to clipboard
Copied
The problem is with your last line of code. Since you didn't use if-else if-else it only applies to your last if-statement, which means that most of the time the value will probably be empty (unless the last drop-down happens to be "K - RST after or on IDT").
There are also several syntax errors in your code and it's quite of cumbersome. I would do it like this:
event.value = "";
var selectedPackageFields = this.getField("Dropdown5").getArray();
for (var i in selectedPackageFields) {
if (selectedPackageFields.value=="K - RST after or on IDT") {
event.value="COL, Chief of Staff";
break;
}
}
Copy link to clipboard
Copied
Maybe I'm doing something wrong but it only seems to work on the last dropdown only.
Sorry but if you could explain it bit more (again no java or programming experience)
Copy link to clipboard
Copied
The code I provided should work. If it doesn't you'll need to share the file with us for further help.
Copy link to clipboard
Copied
Never mind I was being dumb and had accidentally inputted extra characters.
You guys are a big help with this
Copy link to clipboard
Copied
Why can't you copy and paste?
Copy link to clipboard
Copied
Not sure. it may be a setting that is stopping me from doing it. I tried to also right click and copy/paste but that also doesn't work.