Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Sum multiple fields then multiply answer by 1.5

Avatar

Level 1

Hi,

I have an order form with 3 boxes (box1,box2,box3).  Numbers or quantities will be put into these boxes(i.e. I want to order 1 of those and 2 of these and they cost $1.50 each).   I then need to add up the numbers in those three boxes and multiply it by $1.50.  I can get the addition to work but it won't recognize the multiplier.  Can anyone help me?

5 Replies

Avatar

Level 6

I would use some thing similar to following JS code in "calcuate" event of the totalCost value goies to .....

if (!box1.isNull && !box2.isNull && !box3.isNull) {

     this.rawValue = (box1.rawValue + box2.rawValue + box3.rawValue) * 1.5;

}

Avatar

Level 1

It Worked!   But I noticed that if I don't fill in all three boxes it won't calculate.  Is there something that needs to be in the code telling it to ignore

the empty boxes?  I thought the "isNull" did that...

Avatar

Level 1

Worked perfect! But I noticed that if all the boxes didn't have a number in them, it wouldn't calculate. Do I have to put something into the code to ignore boxes that don't have numbers in them?

You can't imagine how much I appreciate your help - Thank You...

Avatar

Level 6

Yes as you guessed isNull is the magic word that does that.

Let me ask you this .....You want to calculate the value even if one of the three boxes are filled in right?

Let us change the code little bit and find out if it does what you need.....use the following to see it meets your requirement.

if (!box1.isNull || !box2.isNull || !box3.isNull) {

     this.rawValue = (box1.rawValue + box2.rawValue + box3.rawValue) * 1.5;

}