Page 1 of 1

onselect javascript help

Posted: Sat Aug 06, 2011 10:51 am
by amc
In database-driven auto-complete textboxes, i usually just use pui.click & process the selected item in rpg.

In the code I am presently working on , I would like to process the selection in JavaScript.

The help in the designer says that the selected item will be passed as a JSON object to my function. I suppose that it will look like this ?

Code: Select all

{"fieldName1":"value1","fieldName2":"value2"}
So, if I have a function like this

Code: Select all

function processSelected(o){
alert(o.fieldName1)
}
what is the name of the JSON object that I should be putting in the onselect attribute of the textbox ?

Code: Select all

processSelected(?)
or am I way off the track here ?

Any help appreciated.

Thanks & regards

Tony C

Re: onselect javascript help

Posted: Tue Aug 09, 2011 10:41 am
by Rob
in the onselect property, add the name of your function without any parenthesis or parameters.

for example processSelected


when you define the function you would do it as you suspected

Code: Select all

function processSelected(o){
alert(o.CATID);

}
in my case, I used PUISAMPLES/CATEGP as the database file. CATID is the field name passed in the JSON object.