Calculations not working - combo box quantities at different price points

Community Beginner ,
Apr 27, 2019

Copy link to clipboard

Copied

I have written this code for a combo box (qmblu) with the quantities as seen in the formula, but the only value displaying is for qty=1 (I checked by changing the numbers to 1, 2, etc, instead of 12.22 and '1' showed in the price field). Even the else "" is being ignored with default on the first value. Can anyone please tell me what I'm missing? The combo box works - my product of the two fields changes based on quantity changes, but always multiplies by the same price.

I'm not a coder; created this based on Thom Parker's articles, but it makes sense to me...

Thanks!

var qty = this.getField("qmblu").value;

if( qty=1 ) event.value = 12.22;

else if( qty=2 ) event.value = 12.22;

else if( qty=3 ) event.value = 12.22;

else if( qty=4 ) event.value = 12.22;

else if( qty=5 ) event.value = 10.80;

else if( qty=10 ) event.value = 10.44;

else if( qty=20 ) event.value = 10.44;

else if( qty=50 ) event.value = 9.72;

else if( qty=100 ) event.value = 9.36;

else if( qty=200 ) event.value = 9.36;

else event.value = "";

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

the comparison operator is "==".  A single "=" is an assignment operator, so the first "if" condition is always true.

Change all of the "if" comparisons to use "=="

if(qty==1)

...etc...

TOPICS
Acrobat SDK and JavaScript

Views

113

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Calculations not working - combo box quantities at different price points

Community Beginner ,
Apr 27, 2019

Copy link to clipboard

Copied

I have written this code for a combo box (qmblu) with the quantities as seen in the formula, but the only value displaying is for qty=1 (I checked by changing the numbers to 1, 2, etc, instead of 12.22 and '1' showed in the price field). Even the else "" is being ignored with default on the first value. Can anyone please tell me what I'm missing? The combo box works - my product of the two fields changes based on quantity changes, but always multiplies by the same price.

I'm not a coder; created this based on Thom Parker's articles, but it makes sense to me...

Thanks!

var qty = this.getField("qmblu").value;

if( qty=1 ) event.value = 12.22;

else if( qty=2 ) event.value = 12.22;

else if( qty=3 ) event.value = 12.22;

else if( qty=4 ) event.value = 12.22;

else if( qty=5 ) event.value = 10.80;

else if( qty=10 ) event.value = 10.44;

else if( qty=20 ) event.value = 10.44;

else if( qty=50 ) event.value = 9.72;

else if( qty=100 ) event.value = 9.36;

else if( qty=200 ) event.value = 9.36;

else event.value = "";

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

the comparison operator is "==".  A single "=" is an assignment operator, so the first "if" condition is always true.

Change all of the "if" comparisons to use "=="

if(qty==1)

...etc...

TOPICS
Acrobat SDK and JavaScript

Views

114

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 27, 2019 0
Adobe Community Professional ,
Apr 27, 2019

Copy link to clipboard

Copied

the comparison operator is "==".  A single "=" is an assignment operator, so the first "if" condition is always true.

Change all of the "if" comparisons to use "=="

if(qty==1)

...etc...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2019 0
Community Beginner ,
Apr 27, 2019

Copy link to clipboard

Copied

Thank you so much Thom. I appreciate having had the chance to read all your detailed articles to at least figure most of it out, but especially want to say thanks for such a quick reply. It works great!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2019 1
Adobe Community Professional ,
Apr 27, 2019

Copy link to clipboard

Copied

You're welcome. I'm glad you found the articles useful.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2019 0