Populate a fiend by DB query according to upper radio option

Hi,I want to populate a fiend by a MySQL DB queried value according to upper field selection.All in the same form;
I have Radio option (this radio items also by lookup);
According to the option selection, it will run SQL query in DB and populate the value in a fiend below instantly.

How to do that? Thanks.

You may use “Lookup_Selecting” server event; and see Example 3 and Example 5 from the Help file. For more info, please read “Server Events and Client Scripts” topic from that Help file.

Hi, thanks for your comment.I am still not sure how to use this. Actually what i want to do is: in a form for example --‘Field_Fruit_Type_ID’ getting radio/select option gets “Apple” , “Orange” by lookup ‘Fruit_Type’ DB table.
Once front end user select an option “Apple” for example; it should populate a locked ‘Fiend_Price’ by price (ex: $3) by querying DB Table ‘Price_list’.

How to do that? Thanks.

Do you mean AutoFill? You may see the topic Lookup Table → Auto Fill in the help file.

arbei wrote:
Do you mean AutoFill? You may see the topic Lookup Table → Auto Fill in the help
file.Hi Thanks, no, its not AutoFillit will query for DB in another table for matching value according to another previous field choice.

------ as i mention above ----
in a form for example --‘Field_Fruit_Type_ID’ getting radio/select option gets “Apple” , “Orange” by lookup ‘Fruit_Type’ DB table.
Once front end user select an option “Apple” for example; it should populate a locked ‘Fiend_Price’ by price (ex: $3) by querying DB different Table ‘Price_list’.so these 2 fields values are coming from 2 different tables.How to do that? Thanks.

You may create a view to join Fruit_Type and Price_list first, then use the view as lookup table and use Auto-Fill to fill the price.

arbei wrote:
You may create a view to join Fruit_Type and Price_list first, then use the
view as lookup table and use Auto-Fill to fill the price.Hi, Thanks for your advice. But actual project is much complex and auto filled value actually come from the combination of 3 options (each from different table) and 1 date. Depends of selection SQL will change. There are multiple fiends to auto fill. Some are after calculations.

If I can define function for each form to call them ‘onClick’, ‘onChange’, etc. it would be much better.Please advice. Thanks.

You may actually use the logic from the code in “Example 4” under the “Ajax by API and Client Scripts” sub topic under “Lookup Table”.

Please read “Lookup Table” topic from PHPMaker Help menu for more info.