The CreatorCon Call for Content is officially open! Get started here.

required help on multiplying two fields

parnika1
Kilo Contributor

Hi All,

 

Kindly provide solution for this.

 

I have two fields[Input Value is Numbers (a,b)] .On the third field[c] , I want the result of(a*b).

The problem I am facing is both [a,b] can be editable. If I write onchange Client script  on A and if B value is edited. then c is populated with (a*b), where b is the old value but not the new value. Kindly help me in achieving this solution

1 ACCEPTED SOLUTION

Hey Mate,

 

While you can write onChange on both fields, but again if B value is edited first then it will still take old Value of A. So till value of A is changed you still see the result of new Value of B X old value of A in field C.  --> Why would this happen?? It will take the new value if you use that each time.

 

Had these scripts been querying server or something heavy I might have suggested doing this on submit/save only. But these are light weight calculations and important form a user perspective, so you want to see the result of change without having to save/submit the records. 

 

Here is the scripts, client side, for A and B and working perfectly

find_real_file.png

find_real_file.png

 

find_real_file.png

 

-Anurag

-Anurag

View solution in original post

13 REPLIES 13

this in on issue form , so I cannot work the logic with BR and 2 onchange client scripts is also not a solution. Is there any other way to achieve this

Hello Pranika,

If you are sure that B value will be chnged only after value A then simply keep the onChange client script on B field.

var val = g_form.getValue("A");

var c = parseInt(newValue) * val;

g_form.getValue("c",c);

Hi,

Can you explain why the onchange client script is not an option? What scenario is it not covering?

-Anurag

-Anurag

Hi, 

I tried the same code but the total is getting populated by multiplying by itself.find_real_file.png