remove selected attribute of first selected element in select tag?
<p>i have a multiple select tag, look at script please</p>

<pre><code>&lt;select multiple="multiple" size="5" id="cities_select"&gt;
     &lt;option value="1"&gt;city1&lt;/option&gt;
     &lt;option value="2"&gt;city2&lt;/option&gt;
     &lt;option value="3"&gt;city3&lt;/option&gt;
     &lt;option value="4"&gt;city4&lt;/option&gt;
     &lt;option value="5"&gt;city5&lt;/option&gt;
     &lt;option value="6"&gt;city6&lt;/option&gt;
     ................................
&lt;/select&gt;
</code></pre>

<p>and jquery script:</p>

<pre><code>$("#supply_cities_select").change(function()
{
    var i = 1;
    $('#supply_cities_select :selected').each(function(u) 
    {
         src += '&amp;c'+i+'='+$(this).val();//generates the string like &amp;c1=1&amp;c2=2&amp;c3=7...
         i++;
    });
})
</code></pre>

<p>i need my string not to have elements greater then 5</p>

<p>example:</p>

<p>if i allready have 5 selected elements, my string looks like</p>

<pre><code>&amp;c1=2&amp;c2=3&amp;c3=5&amp;c4=6&amp;c5=7
</code></pre>

<p>now if one more option will be selected, i need to get the string</p>

<pre><code> &amp;c1=3&amp;c2=5&amp;c3=6&amp;c4=7&amp;c5=8
</code></pre>

<hr>

<p><strong>if be short</strong>, i need to remove selected attribute of first selected element.</p>

<p>(but i can't use <code>.first</code> here, because it can be element N8 the first selected)</p>

<p>how can i do it?</p>

<p>Thanks a lot.</p>

<p>UPDATE</p>

<pre><code>var a = $("#supply_cities_select :selected").length;
if(a &gt; 5)
{
     $("#supply_cities_select :selected:lt(1)").attr("selected",false);
}
</code></pre>

<p>it just remove the firs selected option, isn't it?</p>

<hr>
