Number Formating

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Number Formating

Post by mpol_ch »

Hello
I am using the following number formating with PHPMAKER 10:
74'280'305,00

I am using the following script to autocalculate the field on change. The numbers are in formation such 89000.75 and PHPMAKER is claimin that the format of number is not correct.

Is there a way use the number of formating easily for this script?

thanks
mpol_ch

$("#x_Vortrag").change(function() {
var p1 = $("#x_Vortrag").val();
var p2 = $("#x_Betraege").val();
var sump = +p1 + +p2;
var m1 = $("#x_Leistungen").val();
var m2 = $("#x_Anlagen").val();
var summ = +m1 + +m2;


$("#x_Endbestand").val((+sump - +summ).toFixed(2)) ;


mobhar
User
Posts: 11767

Post by mobhar »

Make sure the field type is double, and the number format has been setup to double from Fields setup.


danielc
User
Posts: 1601

Post by danielc »

The validation is based on your decimal separator defined. In your case, it is ",". So, you need to use str.replace(".", ",") to change the decimal separator to pass the validation.


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Hallo danielc

thankd for the hint. Where should I just insert the replace code? Is the following code correct?

$("#x_Endbestand").val((+sump - +summ).toFixed(2)).replace(".", ",") ;

mpol_ch


danielc
User
Posts: 1601

Post by danielc »

Try:
$("#x_Endbestand").val(((+sump - +summ).toFixed(2)).replace(".", ",")) ;


mpol_ch
User
Posts: 877
Location: Switzerland

Post by mpol_ch »

Dear danielc

thanks a lot for your input. It is working perfectly.
Just another question: Is that possible to format in same way to separate the thousand numbers?

Exp: 5234056,67 should be 5'234'056,67

Thanks any way.

mpol_ch


danielc
User
Posts: 1601

Post by danielc »

You can refer to ewp10.js under phpjs subfolder and search for "//Add the thousands separator".


Post Reply