How to filter query link by another fields webform

I have a Category field, and also a Subcategory that should appear and filter based on the “Category” selection. I managed to do the filtering in Doctype. But I’m still stuck if it’s done in Webform. Every time I select a category, all the subcategories still appear, they are not filtered. Can anyone help?