copy textField value

Questions, tips and tricks and techniques for scripting in Servoy

copy textField value

Postby tkilshaw1553613063 » Tue Apr 16, 2019 12:21 am

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
tkilshaw1553613063
 
Posts: 18
Joined: Tue Mar 26, 2019 5:11 pm

Re: copy textField value

Postby Joas » Tue Apr 16, 2019 9:52 am

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.
Joas de Haan
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 808
Joined: Mon Mar 20, 2006 4:07 pm
Location: Amersfoort, NL

Re: copy textField value

Postby tkilshaw1553613063 » Tue Apr 16, 2019 5:25 pm

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
tkilshaw1553613063
 
Posts: 18
Joined: Tue Mar 26, 2019 5:11 pm

Re: copy textField value

Postby Joas » Tue Apr 16, 2019 5:53 pm

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 128 times
Joas de Haan
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 808
Joined: Mon Mar 20, 2006 4:07 pm
Location: Amersfoort, NL

Re: copy textField value

Postby tkilshaw1553613063 » Wed Apr 17, 2019 12:09 am

Joas,

that makes sense - for the first time!

many thanks,

Terry
tkilshaw1553613063
 
Posts: 18
Joined: Tue Mar 26, 2019 5:11 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 1 guest