Page 1 of 1

Can you retrieve any or all Element properties?

Posted: Wed Aug 14, 2019 11:36 am
by Wendy
I have a 'select box' widget type that displays a long text field on the screen for selection, and (as is typical) sends a different field back to the RPG program for processing. Following is what the element's properties look like:
id = WHDROPDOWN
widget type = select box
value = WHDSC
choices database file = INJSUMWRK
choices options field = INJWHDESC
choices values field = INJWH

I want to take this 'select box' element's 'choices options field' property and send it to a hidden 'textbox' element on the screen, also for use in the RPG program.

I've tried the following methods and neither have worked. I've entered this code in the Onchange Event:

var lctndesc = getObj("WHDROPDOWN").pui.properties["choices options field"];
applyProperty('LOCDESC', 'value', lctndesc);
applyProperty('LOCDESC', 'field type', 'textbox');

------------------

var lctndesc = this.pui.properties["choice options field"];
applyProperty('LOCDESC', 'value', lctndesc);
applyProperty('LOCDESC', 'field type', 'textbox');

Thank you!
Wendy

Re: Can you retrieve any or all Element properties?

Posted: Wed Aug 14, 2019 12:39 pm
by Scott Klement
Do you really want to put the name of the field "INJWHDESC" into the text box? (That is what the code you posted seems to be trying to do.) Or are you looking for the contents of the database's INJWHDESC field for the option that the user selected? (The contents are not in a property, but are in the options of the select box.)

Re: Can you retrieve any or all Element properties?

Posted: Wed Aug 14, 2019 1:05 pm
by Scott Klement
Was thinking about this... you almost certainly want the text that's displayed in the select box.

Assuming you want to do this in the "onchange" event (like one of your examples) you'd code this:

Code: Select all

pui.set("LOCDESC", this.options[this.selectedIndex].text);
The disadvantage to doing it during "onchange" (sorry, if this is obvious) is that it'lll only run the code if the user changes the element. For example, if the select was already selected, it won't do anything. (Even if the user clicks the same element again, it won't be considered a "change", since it's the same.)

But, maybe that's the only time you need it in your situation?

Or, maybe now that you know how to get the text, you can adapt it as needed.

Re: Can you retrieve any or all Element properties?

Posted: Wed Aug 14, 2019 1:36 pm
by Wendy
Thank you Scott!

Yes I definitely wanted to put the contents of the database field INJWHDESC in to the textbox element LOCDESC. I just didn't know how to do it. I only need to capture this any time it changes. I have no default for my select box element and the user will be forced to make a selection.

It worked perfectly as per your usual!

Thanks again, Wendy