Change Selected Option in Drop-Down List

Change Selected Option in Drop-Down List

I want to change the selected <option> in a <select> element when certain criteria are met. 

Here's the scenario:

I have a form with two drop-down menus.
Drop-down menu #1 holds all main categories.
Drop-down menu #2 holds all sub categories

I want drop-down menu #2 to only show categories that belong to the selected item in drop-down menu #1.


When I get rid of the old selected item, the drop-down menu breaks.
E.g When I added:
  1. //Remove the old selected attribute
  2. $(oldSubCategorySelected).removeAttr('selected');

If you remove that line, the drop-down almost does what I want, however it's still got the old sub-category selected.

Would anyone know of how to remedy this? Perhaps I'm going about it the wrong way?