kit kat - 1 month ago 5x
Javascript Question

# (Solved) How To Divide Amount To Dynamic Parameter

I have a problem with some calculation regarding how to divide such amount into dynamic parameter. Let I show the 2 scenario below:-

I have dynamic label like XT and XO where XO should be half from XT after amount a divide.

``````Scenario 1:
Amount = 200
XT = 100
XT = 100

Scenario 2:
Amount = 200
XO = 50
XO = 50
XT = 100
``````

This label XO and XT are dynamic where can be add more or delete, than I need do recalculation again.

I think you need this small logical to do that, the rest you should do you self.

Let me show my syntax on javascript what I know:-

``````            ttrans = (Number(tfull) * 2) + (Number(thalf) * 1);
dfamt = Number(damt) / Number(ttrans)*2;
dhamt = Number(dfamt) / 2;
``````

Let me explain what are variable stand for

1. tfull is your total count XT, u need to count how many XT are appear
2. thalf is your total count XO

3. ttrans is total (XT*2) + (X0*1) - u need that

4. dfamt is amount should be assign to XT
5. dhamt is amount should be assign to XO

That all for the calculation and assign each value even your XT or XO are dynamic OR your amount are change this syntax above will help you re-calculate.