how to add input fields and dropdown and sub drop down by click on button using javascript or jquery

how to add input fields and dropdown and sub drop down by click on button using javascript or jquery

I am trying to add input fields and one dropdown by click on button,one more thing is if I select dropdown value another sub dropdown should show based on the selected value of first dropdown.


I was trying to add fields it has done and  remove  also happening and sub dropdown is not happening.

in that case if select test1 sub drop down is coming like test11,test12, then when select second row field test2 it is coming test21,test22 sub dropdown but first row test11,test12 sub drop down is became test21,test22 but it should not like that ,may it happen like this bez i am using class name.

one important thing is how can insert  those data into Mysqli table when we click the submit button.