Skip to main content
Participating Frequently
Mar 21, 2023 1:16 PM UTC
Question

Online form with 2 dropdowns selections displaying in textfield

Hi.

I am kind of a beginner in creating scripts in adobe and need some help with what i think is a very simple solution. i have tried to look and try soultions in forums, with no luck.I am creating an online form where I have two dropdowns with 5 export values in drop1 and 2 export values i drop2. depending on the combination of the two i want to display a price in a textfield. if none or only dropdown is selected, it should display 0,-

Can anybody please help me?

 

Kind regards Martin

 

This topic is closed to new replies. Start a new post to keep the conversation going.

10 replies

try67
Community Expert
Community Expert
Mar 21, 2023 1:41 PM UTC

You can use something like this code as the custom Calculation script of the text field (adjust the field names as values as needed, of course):

 

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

if (v1=="Option1" && v2=="Option2") event.value = 10;
else if (v1=="Option1" && v2=="Option3") event.value = 15;
else if (v1=="Option2" && v2=="Option1") event.value = 23.4; // etc.
else event.value = "";
Translate
Participating Frequently
Mar 21, 2023 1:47 PM UTC

Thanks for the quick reply, i`ll try that.

 

Translate
Participating Frequently
Mar 21, 2023 2:01 PM UTC

I got an "unexpected field v1". Just to let you know, im doing this in web form in adobe.

here is my code:

var v1 = this.getField("modell").valueAsString;
var v2 = this.getField("avtale").valueAsString;

if (v1=="1" && v2=="a") event.value = 1.990;
else if (v1=="1" && v2=="b") event.value = 2.490;
else if (v1=="2" && v2=="a") event.value = 2.490;
else if (v1=="2" && v2=="b") event.value = 2.990;
else if (v1=="3" && v2=="a") event.value = 2.990;
else if (v1=="3" && v2=="b") event.value = 3.990;
else if (v1=="4" && v2=="a") event.value = 2.490;
else if (v1=="4" && v2=="b") event.value = 2.990;
else if (v1=="5" && v2=="a") event.value = 2.990;
else if (v1=="5" && v2=="b") event.value = 4.990;
else event.value = "";

Translate