Display a field of one content type based on another selected value Screen Preview

I am using DRUPAL 7. I have created  custom content types credit card detail. When adding a new card I want to select the country first and based on that loads related banks in the second drop down. I need help to resolve this issue.Thanks.

Note: country list is loading from countries module, where banks from a db table.
You will have to use AJAX.

Using hook_form_alter you can add ID to the element which needs to be changed.

function MYMODULE_MYFORM_ID_form_alter(&amp;$form, &amp;$form_state, $form_id) {

 //First add id to the field to be changed

  $form ['field_bank'][LANGUAGE_NONE][0]['value']['#prefix'] = '&lt;div id="replace_textfield_div"&gt;';
  $form ['field_bank'][LANGUAGE_NONE][0]['value']['#suffix'] = '&lt;/div&gt;';


//Then you can add AJAX to the countries field like this:

$form ['field_country'][LANGUAGE_NONE][0]['value']['#ajax'] = array(
  'callback' =&gt; 'MYMODULE_ajax_callback',                  
  'wrapper' =&gt; array('replace_textfield_div')
          );
 }


Now in your ajax callback function:

  function MYMODULE_ajax_callback(){
    $country = $form_state['values']['field_country'];

      if($country == 'US'){

             $options = array('Bank1'=&gt;'Bank One', 'Bank2'=&gt;'Bank Two');
           // and so on . You can Load Banks from DB_TABLE and place them here according to your need
             $form['field_bank']['#options'] = $options;   

       }
   //AND OTHERS according to your requirement

  return  $form['field_bank'];

   }


Please remember to rename the fields according to your forms and requirements.