Get value from dropdown

Hi everyone, I am trying to read a value from the dropdown to display it in another dropdown, it worked like a charm at first then all of sudden stopped working.

I have two dropdown fields
1- productcode
2- relatedproducts

in the 2nd dropdown the Data source is:

SELECT DISTINCT relatedproducts as value FROM tblproducts WHERE productcode=:queryprod

$query_params[‘queryprod’] = request()->get(‘productcode’);

anyone can advice? thank you

I managed to fix it by using:

$query_params[‘queryprod’] = request()->lookup_productcode;