5 Replies Latest reply on Feb 10, 2017 7:43 AM by andrewb83719370

# Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges (1 - 1 to 50; 2 - 51 999 3 - 1000 to 2499 4 - 2500 & up). The table looks like this: QTY Choice1 Choice2 Choice3 Choice4 Total Price!

• ###### 1. Re: Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

You'll need to better explain how the total price should be calculated... It's not clear from the information you provided.

It seems that the quantity should be multiplied by the price that corresponds with it, but in your screenshot the result for first row is not \$0.56, but \$1.00... Why is that?

• ###### 2. Re: Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

It will also be helpful to know the names of the fields involved.

• ###### 3. Re: Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

For example, the first line (Part # G 2027).

If I write in the cell QTY (quantity) - 10, the Total Price cell should have result from multiplying 10 by 0.56 !

If I write in the cell QTY  (quantity) - 51, the Total Price cell should have result from multiplying 51 by 0.47

If I write in the cell QTY (quantity)  - 1000, the Total Price cell should have result from multiplying 1000 by 0.45

If I write in the cell QTY  (quantity) - 2500, the Total Price cell should have result from multiplying 2500 by 0.43

Thank you.

• ###### 4. Re: Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

OK, that's what I thought, but your example did not show the same results, which was confusing. Also your field names don't seem very consistent. I suggest you rename them to something like Qty1, UP1_1, UP1_2, UP1_3, UP1_3 and Total1.

Let's say that's the case. Then you can use this custom calculation script for Total1:

```var qty = Number(this.getField("Qty1").value);
var unitPrice = 0;
if (qty>=1 && qty<=50) unitPrice = Number(this.getField("UP1_1").value);
else if (qty>=51 && qty<=999) unitPrice = Number(this.getField("UP1_2").value);
else if (qty>=1000 && qty<=2499) unitPrice = Number(this.getField("UP1_3").value);
else if (qty>=2500) unitPrice = Number(this.getField("UP1_4").value);
event.value = qty*unitPrice;
```
• ###### 5. Re: Please help with (the script). Necessary to multiply the two cells. The first is the QTY (set by hand). The second cell is given a choice between four ranges.

Thank you so much. Everything worked out.