Skip to main content
Participating Frequently
February 28, 2024
Question

3 dropdown menus to auto populate 1 textbox depending on selection

  • February 28, 2024
  • 2 replies
  • 1932 views

I am trying to get a 3 dropdown menus to autopopulate a text box dependant on the choice selected in the dropdown. 

This is formula that I have so far, when I do it for one of the dropdown menu's it works fine, but I'm having issues when trying to add another dropdown menu. 

Can you please advise.

The formula is below 

 

var Item = this.getField("Sponsorship Level").value;

switch(Item){

case "Production Sponsor (Musical)":

event.value = "7500";

break;

 

case "Production Sponsor (Play)":

event.value = "6000";

break;

 

case "Benefactor":

event.value = "3600";

break;

 

case "Benefactor B&W Ad":

event.value = "3500";

break;

 

case "Backer":

event.value = "2500";

break;

 

case "Backer B&W Ad":

event.value = "2375";

break;

 

}

 

 

}

 

This topic has been closed for replies.

2 replies

Participating Frequently
February 29, 2024

Update: if this makes my end goal more clear:

 

I have 3 different dropdown boxes

  • Sponsorship Level
  • Ad Size
  • Premium Positioning

 

I need the dropdowns to feed into 1 text box 

  • Cost

 

The ideal is to code this in a way where the each dropdown option would be able to have a numerical value conencted to it in the coding and add up as they choose their options. 


On top of this, I would like to have the dropdown influence other dropdown menus. 

Meaning: 

Sponsorship Levels:

If you choose :

Production Sponsor (Musical) then the Ad Size option would be FULL PAGE (4.67"w x7.67"h) COLOR and the Premium Position options would be  Back Cover, Front Inside Cover, Back Inside Cover

etc...

try67
Community Expert
Community Expert
February 29, 2024

We understood. The code you were given will do that.

Participating Frequently
February 29, 2024

Thank you, However, when I copy the code and then put in the proper "titles" it gives me a syntax error or it doesn't populate the cost field. 

try67
Community Expert
Community Expert
February 28, 2024

Don't use a switch command. Use an if statement with multiple conditions, like this:

 

var v1 = this.getField("Dropdown1").valueAsString;
var v2 = this.getField("Dropdown1").valueAsString;
var v3 = this.getField("Dropdown1").valueAsString;

if (v1=="A" && v2=="A" && v3=="A") event.value = "A-A-A";
else if (v1=="A" && v2=="A" && v3=="B") event.value = "A-A-B";
else if (v1=="B" && v2=="A" && v3=="C") event.value = "B-A-C";
// etc.
else event.value = "";
Participating Frequently
February 29, 2024

Thanks! When I use this formula and plug in my labels it says:

 

Syntax Error: missing ) after argument list

3: at line 4

try67
Community Expert
Community Expert
February 29, 2024

Post your code.