I am not sure if Select tag is the best way to go, but here is what I have:
<select size="20" style="width:25%;">
<option>State 01</option>
<option>City 01</option>
<option>City 02</option>
<option>City 03</option>
<option>State 02</option>
<option>City 01</option>
<option>State 03</option>
<option>City 01</option>
<option>City 02</option>
</select>
Currently I am seeking advice and suggestions. Long story short, this box will be placed next to a map and when a specific state is selected, it will be shown on the map and I am hoping to show a list of cities for that state (only when the state is selected, not before). And then the user can select a city from the options to see on the map. If another state is selected, a new "dropdown" of cities will be shown for the newly selected state and the previously selected state's cities will go into hiding again.
I have seen code with select optgroup tag (https://stackoverflow.com/a/9892421/5003918), but I am wanting the hide-show functionality as well.
Should I just have two separate select boxes? One with states filled in, and another (initially empty) which will be filled in with cities when a state is selected? Or perhaps an unordered list? Zero or one state will be selected at any given time.