Changing a select menu with Jquery when radio is checked

Changing a select menu with Jquery when radio is checked

Hi i seem to be having a little problem with my code and was wondering is someone could point me in the right direction with it.

What i am doing is if a radio button is selected it will show a different set of city names.

My Jquery code is as follows : 

  1. $(function() {
  2. $( "#accordion" ).accordion({
  3. collapsible: true
  4. });
  5. $( "#citta_az" ).buttonset();
  6.                //Hide Monza e Brianza when page loads
  7. $("#MB_DIV").css("display","none");

  8. // Click Function
  9.   $("#citta_az_mb").click(function(){
  10. // If  MB Is checked
  11. if ($("#citta_az_mb").is(":checked"))
  12. {
  13. //show Monza e Brianza Città
  14. $("#MI_DIV").hide("fast");
  15. $("#MB_DIV").show("fast");
  16. }
  17.                 //Else if MI is checked
  18. else if ($("#citta_az_mi").is(":checked"))
  19. {   
  20. //otherwise, hide it 
  21. $("#MB_DIV").hide("fast");
  22. $("#MI_DIV").show("fast");
  23. }
  24.  });
  25. });
My HTML Code is as follows :

  1. <input name="citta_az" type="radio" id="citta_az_mi" value="MI" checked><label for="citta_az_mi">MI </label>
  2.          
  3.           <input name="citta_az" type="radio" id="citta_az_mb" value="MB">
  4.         <label for="citta_az_mb">MB</label>
  5. <div id="MB_DIV">
  6.       <select name="citta_az_mb" id="citta_az_mb">
  7.       <?php
  8. foreach ($_Citta_MB as $pts => $name)
  9. {
  10. echo '<option value="'.$pts.'">'.$name.'</option>';
  11. }
  12. ?>
  13.       </select>
  14.       </div>
  15.       <div id="MI_DIV">
  16.       <select name="citta_az_mi" id="citta_az_mi">
  17.       <?php
  18. foreach ($_Citta_MI as $pts => $name)
  19. {
  20. echo '<option value="'.$pts.'">'.$name.'</option>';
  21. }
  22. ?>
  23.       </select></div>
The problem i am having is that when i click MB it will show mb but if i click MI again it will not show again.

I hope someone can help with this.

Thanks