Get the value of a field

The user enters free text into the bak_search field, how do I then retrieve what they keyed in ? I’ve done the following but it doesn;t return the value they keyed into the search variable.

var search = forms.frm_itemList.bak_search
var searchStr = ‘%’ + search + ‘%’ ;

Aploogies if my questions are basic but Iam a high school teacher not a programmer evaluating the product for possible use student classes in our high school

thanks.

Hi,

Sounds that should simply work.
This bak_search field is that the name of the table column or the name of the field on the form ?
If it’s the columnname then forms.frm_itemList.bak_search should work. if it’s the element name then you need to address it like so:
forms.frm_itemList.elements.bak_search
But if it’s the element name you can simply address it’s dataprovider instead.

Hope this helps.

No its not a column of a table but an element, a field defined on the form. So if the user types the value XYZ I’d expect to see XYZ in the field.

So I changed the code to :

var search = forms.frm_itemList.elements.bak_search
var searchStr = ‘%’ + search + ‘%’ ;

but when I dispaly the contents of the variable search it is showing the following:

DataField[bak_search:globals.bak_search]

I want it to be XYZ as what the user keyed in not sure what all that reference to DataField etc is ??

Hi,

It sounds like you don’t have any dataprovider connected to this field. Servoy requires to have a field connected to a dataprovider (table column or a (form) global) to store any value.

Thanks for the hint on the data provider and global variable as I hadn’t set that up correctly.