Sir I have follwing data

var1= '5,487,256.36 '
var2= '245,868.48 '
How to get this sum with Js or with any other method.
Basically I want to use it with PHP.
var3= '5,733,124.84'

Please

Recommended Answers

All 2 Replies

Member Avatar for RudyM

Are your variables in Javascript? And you need to use the Javascript variables in PHP code?

//php
$total = money_format(number_format($var1,2,"",".") +number_format($var2,2,"",".")+number_format($var3,2,"","."));



//js
var total = parseInt(var1.replace(/,/g, "")) + parseInt(var2.replace(/,/g, "")) + parseInt(var3.replace(/,/g, ""));
// it might be parseFloat i havent done it in awhile
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.