Page 1 of 1

change format of text field cause problems

Posted: Sat Sep 01, 2012 5:23 pm
by flsd
Steven,

I have a text field in a subform with format "10000.00". Custom code in JavaScript section works fine and the main form is updated correctly. If I change the format of the text field into euro format "10000,00", calculations don't work, because the Number() function returns NaN. Also, I have used nuNumberise () function with the same result. Is this a bug or am I doing something wrong?

In the above subform, when I am trying to update a numeric field using the following code:

Code: Select all

subr = Number(document.getElementById(PREThis+'subr').value); // user inputs subr
ttsub  = ttssub  + subr ;                                                                       // updates totals in main form correctly
document.getElementById(PREThis+'trd_subr').value = subr;                  // database field "trd_subr" is always zero
the result is always the same. field value remains zero.

Thanks
flsd

Re: change format of text field cause problems

Posted: Mon Sep 03, 2012 2:52 am
by admin
flsd,

subr = Number(document.getElementById(PREThis+'subr').value);
won't work if the format is formatted with a comma

But this should..

subr = Number(nuNumberise(document.getElementById(PREThis+'subr').id));


The wiki documentation was wrong for nuNumberise() but I have now fixed it.. http://wiki.nubuilder.com/tiki-index.ph ... pObjectID_


Steven

Re: change format of text field cause problems

Posted: Mon Sep 03, 2012 10:01 pm
by flsd
Steven,

After changing the format of the text fields in '10.000,00' and using the nuNumberise() function like your example, I still have problems in calculations and to update totals in the main form.

Also, the following SQL statement fails due to the decimal point

Code: Select all

  UPDATE subscriptions SET sbr_amount = 100,00, sbr_net = 50,00 WHERE  subscription_id = '15044279497d51' 
All the above, with format '10000.00' and function Number (), work fine.

Thanks
flsd

Re: change format of text field cause problems

Posted: Tue Sep 04, 2012 6:18 am
by admin
flsd,

you need to give me more information where is 100,00, coming from?

Steven

Re: change format of text field cause problems

Posted: Tue Sep 04, 2012 8:36 am
by flsd
Steven,

It is coming from user input. It is like 'Debit' or 'Credit' in 'GL Transactions' in 'SamplenuFinancial' database.

flsd

Re: change format of text field cause problems

Posted: Wed Sep 05, 2012 2:31 am
by admin
flsd,

You need to nuNumberise() the numbers first.

1000,00 is not valid in php, JavaScript or mysql.

Steven

Re: change format of text field cause problems

Posted: Wed Sep 05, 2012 6:05 am
by flsd
Steven,

The problem is that the nuNumberise () does not convert the format of the text field. For the same reason the calculations fail.

flsd

Re: change format of text field cause problems

Posted: Wed Sep 05, 2012 7:48 am
by admin
flsd,

I can get it working so I don't know what you mean.

Has the text field been given a format?
Capture.PNG
Steven