add selected id to div
<p>I need to get the value = id of the selected department outside the foreach loop code and add it to the div where custom fields will show created for each department. This is for a hook i am coding for IPB</p>

<pre><code>&lt;select id="departments" name="departments"&gt;
    &lt;if test="is_array($dep) and count($dep)"&gt;
       &lt;foreach loop=":$dep as $r"&gt;
           &lt;option value="{$r['id']}"&gt;{$r['name']}&lt;/option&gt;         
       &lt;/foreach&gt;
    &lt;/if&gt;
&lt;/Select&gt;

&lt;div id="" class="depa" style="display:none"&gt;
   test
&lt;/div&gt;

&lt;script type="text/javascript"&gt;
    $(function() {
        $('#departments').change(function(){
            $('.depa').hide();
            $('#' + $(this).val()).show();
        });
    });
&lt;/script&gt;
</code></pre>
