How do you populate dynamic dropdowns based on a number field?

A simple solution is to have a data type with a list of numbers from 1 to x. Then in your dynamic search have a condition that says where number < the number in stock. Then sort so you get 1 > x.