Hi Iuri,
ad_form provides the special __refreshing_p to trigger the -on_refresh section where you can do whatever you want.
The idea is to stop the form processing and to do an intemediate submit where all the form elements from the beginning to the element triggering the submit are available.
The following example shows how to populate the element wh_mov_location_id with only the locations related to the store specified by the preceding element.
{wh_mov_store_id:integer(select)
{options { {"Choose" ""} [db_list_of_lists query "
select store_description, store_id
from mis_stores
where plant_id = :plant_id
order by plant_id, store_description
"] }}
{label {Store}}
{html {onChange "document.lineaddedit.__refreshing_p.value='1';document.lineaddedit.submit()"}}
}
{wh_mov_location_id:integer(select),optional
{options { {"Choose" ""} [db_list_of_lists query "
select w.plant_code || ' Store ' || s.store_code || ' ' || l.location_code, l.location_id
from mis_store_locations l, mis_stores s, mis_plants w
where s.store_id = :wh_mov_store_id and
l.store_id = s.store_id and
s.plant_id = w.plant_id
order by w.plant_code, s.store_id, l.location_code
"] }}
{label {Location}}
}
This case is very simple and you don't even need a -on_refresh section.