Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

change format of text field cause problems

Post Reply
flsd
Posts: 32
Joined: Tue Jul 03, 2012 6:50 pm

change format of text field cause problems

Unread post 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
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: change format of text field cause problems

Unread post 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
flsd
Posts: 32
Joined: Tue Jul 03, 2012 6:50 pm

Re: change format of text field cause problems

Unread post 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
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: change format of text field cause problems

Unread post by admin »

flsd,

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

Steven
flsd
Posts: 32
Joined: Tue Jul 03, 2012 6:50 pm

Re: change format of text field cause problems

Unread post by flsd »

Steven,

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

flsd
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: change format of text field cause problems

Unread post by admin »

flsd,

You need to nuNumberise() the numbers first.

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

Steven
flsd
Posts: 32
Joined: Tue Jul 03, 2012 6:50 pm

Re: change format of text field cause problems

Unread post 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
admin
Site Admin
Posts: 2825
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: change format of text field cause problems

Unread post 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
You do not have the required permissions to view the files attached to this post.
Post Reply