Skip to main content
New Participant
August 25, 2023
Question

How to auto populate quantities using 2 drop-down menus

  • August 25, 2023
  • 1 reply
  • 3418 views

Hi, new business owner & new Adobe user here. A couple days into using it & I feel like what I'm looking for is probably super simple for most. If I get the answer here, it will save me an embarrassing amount of time trying to figure it out myself. I'll try my best to explain.

We're creating a form for large quantity clothing orders.
It has 2 drop-down menus (Style: Adult, Youth) and (Size: xs through 4xl) followed by the quantity column. At the bottom of the form I'd like it to auto populate the quantity breakdown - how many Youth XS, how many Adult XS, etc. 

I have the items & values done in the drop downs but I have know idea what the custom script would look like to calculate totals.

Any help would be greatly appreciated.

thanks!

 

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 25, 2023

It's actually not that trivial. You would need to use a for-loop to iterate over all the fields, checking each pair for a certain value, and then incrementing the value of a counter variable if they match what you're after, applying the value of that variable to the total field at the end of the process.

If you let us know what are the names of the fields involved I could help you with a sample code for this.

New Participant
August 26, 2023

I wasn't expecting such a quick response & I really appreciate it. It sounds like this is something i wouldnt have figured out on my own. I attached photos of the form hoping that is more helpful then an explanation from me. I made the export value for each selection in the drop-down menus 1

New Participant
August 26, 2023

OK, then you can use this code to count the number of YOUTH XS selections, for example:

 

var count = 0;
for (var i=1; i<=26; i++) {
	if (this.getField("STYLE"+i).valueAsString=="YOUTH" && this.getField("SIZE"+i).valueAsString=="XS") {
		count++;
	}
}
event.value = count;

 

Place it as the custom Calculation script of the text field where you want the result to appear.


Thanks so much! I'm excited about this working. I entered the code as the custom calculation script in the small text field at the bottom, it appears like it'll work but when i enter totals it still shows 0 in the text field. Is there something else I should change? i attached a photo

thanks again