1

I have two options for select. I am trying to get it to where if the user selects "Case Manager" for option for select #1, then option for select #2 appears (it is currently hidden from the user).

Here is my code:

Haml:

= form_tag app_configurations_path, :method=> 'put' do |f|
  -@all_configurations.each do |config|
      =hidden_field_tag "config_ids[]", config.id
      %label= t('workflow.duplicate_claim_manager')
      = select_tag('duplicate_claim[case_manager]', options_for_select(@case_managers_drop_down, config.configuration_value),name: "config[#{config.id}]", :include_blank => true)

      %label.hidden(for="duplicate_claim_manager_secondary")
      = hidden_field('duplicate_claim_manager_secondary', options_for_select(@case_managers_drop_down, config.configuration_value),name: "config[#{config.id}]", :include_blank => true)

The Haml appears to be correct, but I can't get the Javascript to correctly unhide option for select #2. Any ideas?

if ($("#duplicate_claim_case_manager :selected").text() == "Case Manager") {
   $("#duplicate_claim_manager_secondary).setAttribute(type => text)
}
lakeIn231
  • 1,177
  • 3
  • 14
  • 34
  • 1
    I have no idea how haml works, but I think $(..).setAttribute() will not work, because .setAttribute is js, not jquery, so you can not chain it to a jquery object. Although..... http://stackoverflow.com/questions/34920816/javascript-jquery-chaining .. also you forgot a closing " for the $ selector on 2nd line – yezzz May 02 '16 at 21:27

0 Answers0