Hide/Show checkbox elements based on select box - Javascript

I have code that enables select list 1 to populate select list 2 as taken from a railscast. I want to change the select list 2 to a series of check boxes. I'm not a Javascript person so changing this is making a mess.

This is the 2 select list code in Javascript:

function countrySelected() {   country_id = $('fips_code_country_code').getValue();   options = $('fips_code_state_code').options;   options.length = 1;   counties.each(function(state) {     if (state[0] == country_id) {       options[options.length] = new Option(state[1], state[2]);     }   });   if (options.length == 1) {     $('state_field').hide();   } else {     $('state_field').show();   } }

Any thoughts on how I can convert this so that the only states displayed in the checkbox list are those associated with the selected country? Do I do something with the id element? I think that I need to change line 3 so that it's not looking at the <option>, but rather an id. But again, I have no clue what I'm doing.

Any help would be GREATLY appreciated.