Page 1 of 1

copy textField value

PostPosted: Tue Apr 16, 2019 12:21 am
by tkilshaw1553613063
Well this should be really easy but I have searched the Wiki and the Forums and come up blank.

On a form you have a textField that uses a column as its dataProvider. You want to copy that textField's value to another textField that does not have a dataProvider.

How is that done?

thanks,

Terry

Re: copy textField value

PostPosted: Tue Apr 16, 2019 9:52 am
by Joas
Both text fields should have a dataprovider.

What are you trying to do? The dataprovider of your second textfield should probably be a form- or scope variable.

Re: copy textField value

PostPosted: Tue Apr 16, 2019 5:25 pm
by tkilshaw1553613063
Joas,

thanks for your help.

I am just learning a bit about Servoy. Let me put my question another way.

Suppose that I have a textField that has a column dataProvider and that textField has a numerical value for a record of 25.5.

How can I programatically access the textField's value, multiply it with another number and then display it in another textField?

Terry

Re: copy textField value

PostPosted: Tue Apr 16, 2019 5:53 pm
by Joas
Let's say you have 3 columns: price, amount and total
To calculate the total you want to multiply the price with the amount.
For this you need just one line of code:
Code: Select all
total = amount * price;
Easy, right?

Basically, you don't care about showing the value in the textfield, Servoy handles that for you (automatic data binding)

Here shown in developer where the amount and price fields use the same method on their onDataChange event. So whenever one of them changes, the total is calculated automatically:
script.png
script.png (80.18 KiB) Viewed 3510 times

Re: copy textField value

PostPosted: Wed Apr 17, 2019 12:09 am
by tkilshaw1553613063
Joas,

that makes sense - for the first time!

many thanks,

Terry