Is there a way to keep adding selectbox/text_input by clicking on button?

Hi community, I am trying to build a tool to interact with the database, and help users get data by providing them the option to add filters by clicking on a button. It is pretty similar to what aggrid filters could do but in a more user-friendly way. The problem is whenever selectbox is chosen the script reruns, and I couldn’t figure out a good way of replicating the user’s choice for previous selectboxes. Can anyone give me an idea of how to solve it?