Copy link to clipboard
Copied
I have three dropdown boxes (dropdown A, dropdown B, and dropdown C). How can I get the selection in one to pull information from another and populate in another? For example I have 20 name selections in dropdown A. I have two options in dropdown B which are "yes" or "no". And I have 15 name selctions in dropdown C.
This is what I'm trying to accomplish:
If a user selects "yes" from dropdown B, I would like it to automatically pull their name selection from dropdown A, and input it into dropdown C. However, if the user selects "no" in dropdown B, they would be able to manually select from the 15 names in dropdown C.
Copy link to clipboard
Copied
As the custom calculation script of dropdown C you can use the following code:
if (this.getField("B").valueAsString=="yes") event.value = this.getField("A").valueAsString;
Copy link to clipboard
Copied
As the custom calculation script of dropdown C you can use the following code:
if (this.getField("B").valueAsString=="yes") event.value = this.getField("A").valueAsString;
Copy link to clipboard
Copied
Thank you so much! You've answered a lot of my questions over the years. I am using this page as a template. I've created a button that poultates a new page from this template and changes each field value so they aren't linked. Is there a way to add this scrip to the page since whenever I populate a new page those form fields will no longer be called "B" but will be B1, B2, B3, etc.
Copy link to clipboard
Copied
Glad to hear it!
If the other fields are also named the same, then yes. Try this:
var fieldNumber = event.target.name.replace("C", "");
if (this.getField("B"+fieldNumber).valueAsString=="yes") event.value = this.getField("A"+fieldNumber).valueAsString;
Copy link to clipboard
Copied
Thanks! Where would I add this script? The document script?
Copy link to clipboard
Copied
Hello TRY67!
Firstly thank you for all the help you give out! I was wondering if it is possible to have a drop down box with various different fields to select from. What i am trying to do is when an option from the drop down is selected. I would like to populate multiple text boxes with information for each different drop down selection. I would like different text to be filled from different options from the drop down box. To save keep filling the same text in every time. I hope this makes sense? If not i can try to explain clearer.
Thank you!
Copy link to clipboard
Copied
Sure. You can do it using something like this as the custom Validation script of the drop-down field:
if (event.value=="Option 1") {
this.getField("Text1").value = "ABC";
this.getField("Text2").value = "DEF";
this.getField("Text3").value = "HIG";
} else if (event.value=="Option 2") {
this.getField("Text1").value = "XYZ";
this.getField("Text2").value = "VVV";
this.getField("Text3").value = "ZZZ";
} else {
this.getField("Text1").value = "";
this.getField("Text2").value = "";
this.getField("Text3").value = "";
}
Copy link to clipboard
Copied
Thank you for your response. The code works like a charm! My only question to you is if i want to add more than the first two options to select from the drop down. Do i just add in option 3
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Sorry i figured the above question out. I am now wondering if i can also enable when i select an option from the drop down if it can also trigger a tix box to tick please?
Copy link to clipboard
Copied
Sure. You can use this code:
this.getField("CheckBox1").checkThisBox(0, true);
Or if you know the export value:
this.getField("CheckBox1").value = "Choice1";
Copy link to clipboard
Copied
Hello. Thank you for the help. The drop down code, and also the tick box code all worked like a charm. So thank you very much for the help as i have no clue how to code.
I have one last question for you... i promise. I am wondering if you know if its possible to add an automation for a weight calculation?
What i am after is weight vs net weight. So i already have text 1,2 &3 on the drop down autmation options which aut populates.
Text 3 which says KG71 is where the weight will be populated. I am wondering if i could add text 4 for example and somehow add code to display the net weight as well as the weight. I would somehow have to add code to the drop down to minus the weight and display the net weight. I hope this all makes sense. if not then feel free to let me know and i will provide more information.
Again thank you so much for all the help!
Copy link to clipboard
Copied
Something like this:
if (event.value=="Option 1") {
} else if (event.value=="Option 2") {
} else if (event.value=="Option 3") {
} else {
}