Get selected value from Dropdown list of views I have a drop down list of different views for the users to select on a content type page in Drupal 7. I need to get the value of selected view from the drop down and display it in the form of selected view.

$value = $_GET['select id'];
$view = views_get_view('value');
print $view-&gt;preview('default');


I am not sure from where I should get the ID of the drop down field.
Not sure I fully understand the issue it would help if you asked a direct question. Here are some thoughts though.

To get a list of applicalbe view checkout this funciton form the node reference module:

function references_get_views_options($entity_type) {
  // Filter views that contain a 'references' display. This actually returns a
  // list of displays (the same view appears several times).
  $displays = views_get_applicable_views('references display');

  // Filter views that list the entity type we want, and group the separate
  // displays by view.
  $entity_info = entity_get_info($entity_type);
  $options = array();
  foreach ($displays as $data) {
    list($view, $display_id) = $data;
    if ($view-&gt;base_table == $entity_info['base table']) {
      $options[$view-&gt;name . ':' . $display_id] = $view-&gt;name .' - ' . $view-&gt;display[$display_id]-&gt;display_title;
    }
  }

  return $options;
}


The key function here is the "views_get_applicable_views(&amp;display_type)". The rest of the function just filters the list for an entity type (node, taxonomy term, comment, or user are the common defaults). Then formats the data as an options list.

You can embed this list in a form as so (I wrote this code to do a similar task to what it sounds like you are doing:

$views_options = references_get_views_options('node');
if ($views_options) {
  $views_options = array('' =&gt; '&lt;' . t('none') . '&gt;') + $views_options;
  $element['view_and_display'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('View used to select the nodes'),
    '#options' =&gt; $views_options,
    '#default_value' =&gt; $default_view,
    '#description' =&gt; 'description',
  );


In the submit handler you save the view option. Something like:

$view = $form_state['values']['views_and_display'];


Then in the view hook of the content type you run an embed.

$view_info = explode(':', $display['settings']['view_and_display']);
$result[0]['#markup'] = views_embed_view($view_info[0], $view_info[1], $args);


Hope that helps. I wrote a module that did something similar for a client not too long ago so this is all working code form that module. It actually registers a display handler to output a node reference field as a view so it would give me a list with exactly the correct fields desired.