Skip to main content
Inspiring
March 14, 2021
Answered

Variable Export Values with Drop Menu Choices

  • March 14, 2021
  • 1 reply
  • 1386 views

Creating a merchandise order form.  

 

Text Box (QTY)

Drop Down Menu (SIZE) with selections (XS,S,M,L,XL,2XL, and 3XL)

Drop Down with Color (COLOR)  

Text Box (TOTAL)  

 

In the drop down menu (SIZE) I need the value for sizes XS, S, L, and XL to calculate $25 and 2XL and 3XL to calculate at $28 when selected.  

Currently, (QTY) is Multiplying with (SIZE) to create (TOTAL) I just cant figure out how to have variable prices for size selection.  

Thank you.

 

This topic has been closed for replies.
Correct answer Nesa Nurani

EDIT:

Try this code:

var q = Number(this.getField("QTY").value);
var s = this.getField("SIZE").valueAsString;
var total = 0;
if(s == "XS" || s == "S" || s == "M" || s == "L" || s == "XL")
total = 25;
else if(s == "2XL" || s == "3XL")
total = 28;
event.value = q*total;

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 14, 2021

EDIT:

Try this code:

var q = Number(this.getField("QTY").value);
var s = this.getField("SIZE").valueAsString;
var total = 0;
if(s == "XS" || s == "S" || s == "M" || s == "L" || s == "XL")
total = 25;
else if(s == "2XL" || s == "3XL")
total = 28;
event.value = q*total;

Bernd Alheit
Community Expert
Community Expert
March 14, 2021

Don't use same export values for several entries.

Nesa Nurani
Community Expert
Community Expert
March 14, 2021

Thanks Bernd, I thought so too, I actually just read other post where try67 and Thom said same thing but still I wanted give it a try since it's same price value, and using 'value is' to multiply with QTY didn't give me any errors ( at least from what I tested) so I thought It's safe to use it for this situation?