I am trying to make a script where I populate a second select according to the first <select>
option.
For example, if I select Category 1 on the first <select>
, I need the second one to be populated with Subcategory 1.1, Subcategory 1.2, etc.
Here is my code:
<select id="category">
<option value="">Select Category</option>
<option value="1">Category 1</option>
<option value="2">Category 2</option>
<option value="3">Category 3</option>
</select>
<select id="subcategory">
<option value=""></option>
</select>
I am trying to do this with jquery. Can someone help me with this?