I am trying to get the id of a radio button on click from a Rails 4 form. I am trying to use some jQuery like:
$("input:radio[name=client_account]").click(function() {
var value = $(this).val();
alert(value);
var id= $(this).attr('id');
alert(id);
});
but the "name" of the radio buttons is "client_account[client_account_attributes][org_type]"
I have an "f.collection_radio_buttons" set that is rendering in the form. I want to create a "dynamic form" that will show and hide divs based on answers to certain questions. But I will need to somehow get the id or value from the selected radio button when it is clicked so that I can determine which divs to show / hide.
Here is an example of the HTML in case it will help:
<input type="radio" value="Other" name="client_account[client_account_info_attributes][org_type]" id="client_account_client_account_info_attributes_org_type_other">
thanks in advance!!