With jQuery you can write in simple way to achieve this. Here is the code for populate the state dropdown based on the country dropdown selected value.
New optimized code
The above code has totally 21 lines. This we can optimize to 12 lines. Here is the code.