Expand my Community achievements bar.

What kind of scripting has to be used for these formulas?

Avatar

Former Community Member
Hi All,



I have three requirements which I feel can be done by either JavaScripting/FormCalc or both.



1) If the user enters "99.00" in "New Price" the "% Change" column should get populated.(% difference between Current Price & New Price +/-)



2) If the user enters "+2" in "% Change" the "New Price" should be calculated depending upon the Current Price



3) If the user enters "+2" in "CHANGE ALL PRICES BY" field then the "New Price" for entire table(mass change) should change by +2% of old price

---------------------------------------------

CHANGE ALL PRICES BY : XX %

---------------------------------------------

Current Price | New Price | % Change

$51.73 | $99.00 | +/- ??

$80.90 | ?? | +2

.

.

.

---------------------------------------------



Kindly let me know what will be the code for JavaScript/Form calc to handle each individual issue.



Waiting for help.



--Regards,

VD
6 Replies

Avatar

Level 5
What you are trying to get may be as simple as doing some math. However that calculations should be event driven. I prefer not to use Calculate event on any field as it gets triggered in the form initialization process and may cause issues.



Best events could be 'change' or 'exit'. And have to code on each field that accepts user input. For example



to calculate the %Change you may use following JS code



--this code is based on exit event of NewPrice field---

PercentChange.rawValue = ((this.rawValue - CurrentPrice.rawValue)/CurrentPrice.rawValue)*100;

Avatar

Former Community Member
SekharN,



Thanks for your immediate response.

But how will I do the mass change for a column for entire table?



3) If the user enters "+2" in "CHANGE ALL PRICES BY" field then the "New Price" for entire table(mass change) should change by +2% of old price?



Code for this?



Regards,

VD

Avatar

Level 5
I have no idea how your table is defined, layout. With the example in my previous reply you could code the calculations on your own. If you still have difficulty email me your form template at 'meetsekharv AT yahoo.com' for additional help.

Avatar

Former Community Member
Thanks Sekhar for your support.

I will let you know if I have issues and mail you accordingly



Regards,

VD

Avatar

Former Community Member
Hi Sekhar,



If the user enters "+2" in "CHANGE ALL PRICES BY" (input field) then the "New Price" (column)for entire table(mass change) should change by +2% of "Current Price" . Assume I have 2 columns in table Current and New Price. What will be the script code for looping and changing the values of full column (New Price).

---------------------------------------------

CHANGE ALL PRICES BY : XX %

---------------------------------------------

Current Price | New Price |

$51.73 | ?? |

$80.90 | ?? |

$60.00 | ?? |

.

.

---------------------------------------------

Do let me know if I am not clear.



-VD

Avatar

Level 5
Just replied to an email from Sankar Narayanan.