Page 1 of 2
onselect
Posted: Mon Oct 21, 2013 9:53 am
by oumouna
I have a list box and a text box. I would like for each value selected in the list box, load it into the text box the number corresponding to that value.
I think that I must do this using Javascript with the property onselect of the list box but I have problem with Javascript. I would like a little help please.
Re: onselect
Posted: Mon Oct 21, 2013 10:31 am
by Scott Klement
I don't think there is an onselect property for a list box, is there?
Can you clarify?
Re: onselect
Posted: Mon Oct 21, 2013 11:14 am
by Paul_Ramcharitar
There is no onselect property for a listbox, but you could use its onclick property.
Put this in the onclick of your list box:
Code: Select all
pui.set("TextBox1", pui.get(this))
"TextBox1" is the ID of your text box. So you are setting the value of "TextBox1" to the value gotten from your list box when an item is clicked/selected, "pui.get(this)".
I think the "pui.set()" and "pui.get()" functions are available from version 4.6.5
Re: onselect
Posted: Mon Oct 21, 2013 11:17 am
by oumouna
Scott
I do a mistake, It is a dropdown box, not a list box.
I read this part of the documentation:
"onselect event (Combo Box)
The onselect event for combo boxes activates when a selection is made from the combo choices. The event should be specified as a JavaScript expression."
Re: onselect
Posted: Mon Oct 21, 2013 11:37 am
by Scott Klement
Actually, a "list box" and a "drop down box" are the same thing, except that the list box shows more than one row at a time on the screen. They are the same widget, under the covers.
However, a combo box is different. A combo box allows the user to type their selection as well as selecting it from the choices. When they do select one, the 'onselect' event will fire. Is that what you are using, a Combo box?
Can you also explain more about what is meant by "I would like for each value selected in the list box, load it into the text box the number corresponding to that value."
Re: onselect
Posted: Mon Oct 21, 2013 11:46 am
by oumouna
I thaught that Dropdown box and Combo box are the same.
I have a list of differents pieces (CNI, PA, PC) and for each piece I have a number.
For example for my CNI the number is xxxxxxxxxxxxxxxxxx and for my Passport the number is xxxxxxxxxxxxxxxxxx.
I want that when I choose one of the piece, to load the number matching with that type of piece in the text box.
The datas are in a table of a database.
Re: onselect
Posted: Mon Oct 21, 2013 11:49 am
by oumouna
I am using Combo Box
Re: onselect
Posted: Mon Oct 21, 2013 12:02 pm
by Scott Klement
I would set the "onchange" value of the combo box to pui.click(). When the user makes a change, this will cause control to be returned to the RPG program. The RPG program can then set all of the fields on the screen to the corresponding values.
If you'd like an indicator to be set (to notify the RPG program that the onchange fired) you can put a hidden button on the screen, and do pui.click("id of hidden button"). The response of the button can be bound to an indicator that the RPG program can check for.
Re: onselect
Posted: Mon Oct 21, 2013 12:30 pm
by oumouna
When I do [onchange] pui.click("ID of hidden Button"), when a value is select in the combo box, does this put the button on??
Re: onselect
Posted: Mon Oct 21, 2013 3:03 pm
by Scott Klement
It clicks the button (just as it would if someone clicked it with the mouse.) This way, the button can turn an indicator on and return control to your RPG program, and the RPG program can check for the button being clicked.
IF you make it a hidden button, then the button can only be clicked via pui.click().