Becca Girl
2008-Mar-18 21:42 UTC
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---