How to change a hidden value and the text of the
<p>I am currently attempting to make a dropdown menu where selecting one of the links from the menu will change the hidden value as well as the text of the hyperlink. This is based upon Twitter's Bootstrap dropdown, and uses jQuery:</p>

<pre><code>&lt;div id="periodChooser" class="btn-group"&gt;
   &lt;input type="hidden" value="1" name="dtype" id="dtype1"&gt;&lt;/input&gt;
   &lt;a data-toggle="dropdown" href="javascript:;"&gt;Weekend&lt;/a&gt;  
   &lt;ul class="dropdown-menu"&gt;
      &lt;li&gt;&lt;a href="javascript:;" data-value="1"&gt;Weekend&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="javascript:;" data-value="2"&gt;Week&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="javascript:;" data-value="3"&gt;Midweek&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>The script that I have attempted to write is as follows:</p>

<pre><code>&lt;script&gt;
jQuery(function($){
    $('#periodChooser').each(function() {
        $('.dropdown-menu a').click(function() {
            $('.btn-group').find('input[type=hidden]').val($(this)
                    .data('value')).change();
            $('.btn-group').find('.btn:eq(0)').text($(this).text());
        });
    });         
});
&lt;/script&gt;
</code></pre>

<p>Unfortunately, whilst it doesn't return any specific error, the code does not work. Any suggestions?</p>
