input field works like dropdown

reenageorge5

New Member
Hi,
i Have a filed in my Input screen where i have to select values from a dropdown list ... the values in the dropdown are listed when i press F2.The values in the dropdown are populated from distinct values from a column in a table of dB...If anybody knows send me sample code...
 
/* Just a quick sample to show how you can do it */
/* V 9.1e character on hp-ux but should work on V8 */

on "help" anywhere run p_dropdown (self:handle).
def temp-table t_dropdown
field selfname as char
field dropdown_value as char
field description as char form "x(40)"
index idx1 selfname description.
def query q_dropdown for t_dropdown scrolling.
def browse br_dropdown query q_dropdown
display t_dropdown.description
with 10 down width 60.
form br_dropdown with frame fr_dropdown no-labels 1 down width 70.

run p_testit.
procedure p_testit:
def var this_one as char no-undo.
def var that_one as char no-undo.
def var this_loop as int no-undo.
do this_loop = 1 to 10:
create t_dropdown.
t_dropdown.selfname = "that_one".
t_dropdown.dropdown_value = string (this_loop,"99").
t_dropdown.description = "Item " + string (this_loop,"99").
end.
update this_one that_one with frame f1.
message this_one that_one view-as alert-box.
end procedure.

procedure p_dropdown:
def input param inp_handle as widget-handle.
def var query_value as char no-undo.
find first t_dropdown where t_dropdown.selfname = inp_handle:name no-lock
no-error.
if not available t_dropdown then do:
message "No dropdown is available for" inp_handle:name
"in frame" inp_handle:frame:name
view-as alert-box.
return.
end.
open query q_dropdown for each t_dropdown where t_dropdown.selfname =
inp_handle:name no-lock.
enable br_dropdown with frame fr_dropdown.
wait-for "default-action" of br_dropdown in frame fr_dropdown focus
br_dropdown.
hide frame fr_dropdown.
if available t_dropdown then do:
query_value = t_dropdown.dropdown_value .
inp_handle:screen-value = query_value.
end.
end procedure.
 
Back
Top