How to use dynamic filtering in webform?

I have a Web Form with two fields:

  • Issue Type
  • Issue Sub Type

I want the “Issue Sub Type” options to be filtered based on the selected “Issue Type”, just like how we can do it in a regular form using a custom script. But I’m unable to achieve this in the Web Form.

Can someone please share a working JavaScript snippet or guide me on how to do this in a Web Form?

Thanks in advance!