You need to perform correlation of these dynamic parameters (and any others as well), your test should look as follows:
1. For the previous request sampler
2. Extract values of dynamic parameters using one of JMeter's Post-Processors (I would recommend using CSS/JQuery Extractor for HTML response types)
3. Replace hard-coded parameters with dynamic correlated values in the next request.
You can debug and test your CSS/JQuery expressions using CSS/JQuery Tester mode of the View Results Tree listener.