title: How to display selected text of a dropdown menu and dynamically populate it from an array of strings?
body: <p>I have a dropdown menu using twitter bootstrap. I want to-</p>
  
  <p>a) <strong>Dynamically populate it from an array of strings which I fetch from my database.</strong></p>
  
  <p>b) <strong>Display the selected text of the dropdown as replacing the default dropdown text.</strong></p>
  
  <p>How do I do this?</p>
  
  <p>My current code for the dropdown menu is as follows:</p>
  
  <pre><code> &lt;div class="btn-group" role="group"&gt;
       &lt;button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"&gt;
              Dropdown
    &lt;span class="caret"&gt;&lt;/span&gt;
          &lt;/button&gt;
          &lt;ul class="dropdown-menu" role="menu"&gt;
            &lt;li&gt;&lt;a href="#"&gt;Link 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Link 2&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  </code></pre>