Skip to main content
Participating Frequently
March 21, 2023
Question

Online form with 2 dropdowns selections displaying in textfield

  • March 21, 2023
  • 1 reply
  • 1410 views

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 has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 21, 2023

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 = "";
Participating Frequently
March 21, 2023

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

 

Participating Frequently
March 21, 2023

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 = "";