Jump to content

Add numbers with JavaScript


This topic is 6612 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I look in all the posts and find nothing. So if somebody can help me.

Say I have two fields. One is a name of a project and the other is a total for the project. I can have many records for a project. Something like B)

Field 1 field 2

project1 120,50

project1 50,25

project1 30,25

project2 323,67

project2 63,63

project2 23,67

In a javascript, I want to add the numbers so i can have sub-summary for each project.

In my script in Javascript I have a line like this within a [fmp-record]

TotalProject += "[FMP-Field:TotalBCNet]";

My problem is that it does not add the numbers so the result would be 200,00 for project1 but write Project1 120,5050,2530,25

Does somebody have an answer?



Link to comment
Share on other sites

  • Newbies

I try that too. But then nothing show up in the page. I am french speaking (I hope I don't do much mistakes in writing). In french the way to write the numbers are different. We use the coma to divide the dollars with the cents (1,00 instead of 1.00). In the database, I have a calculation field that change the coma for a point. When I look at the code of the page the numbers are there but nothing appears in the page.

Here is the whole script.

<script LANGUAGE="JavaScript">

var TotalProjet = 0; var TotalParProjet = 0; var Projet = "";


if (Projet == "[FMP-Field:BCProjet]")


TotalParProjet +=[FMP-Field:TotalBCNetAff];

TotalProjet +=[FMP-Field:TotalBCNetAff];




document.write(TotalProjet + " " + TotalParProjet + "<br>");

Projet = "[FMP-Field:BCProjet]";

TotalParProjet += [FMP-Field:TotalBCNetAff];

TotalProjet += [FMP-Field:TotalBCNetAff];

} ;


document.write(Projet + " " + TotalParProjet + "<br>");

document.write("Total : " + TotalProjet);


It's a script that I copy fron that forum which I appreciate a lot. Thank you for the help.


Link to comment
Share on other sites

This topic is 6612 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.