title: deselect item in multiitem listbox with javascript
body: <p>I am trying to deselect item (once selected) when user will click on the item in listbox.
  I have a script which is deselecting the item on user click but that is happening even when the item is selected for first time as well.
  This is what I have:
  JS:</p>
  
  <pre><code> function deselect()
            {
                var list = document.getElementById('&lt;%=ddlCity.ClientID%&gt;');
                var listLength = list.options.length; 
                for (var i = 0; i &lt; listLength; i++) {
                    if (list.options[i].selected) {
                        list.selectedIndex = -1;
                    }
                }
            }
  </code></pre>
  
  <p>And the html:</p>
  
  <pre><code>  &lt;asp:ListBox ID="ddlCity" CssClass="formfield" runat="server" DataSourceID="SqlDataSourceCity"
                  DataTextField="Description" DataValueField="CityID" SelectionMode="Multiple" onclick="deselect();"
                  OnDataBound="DropDownList3_DataBound"&gt;&lt;/asp:ListBox&gt;  
  </code></pre>
  
  <p>Any idea how I can edit that JS to deselect the value once the value is selected, but when user selects the value for first time the value to be selected.
  Thanks, Laziale</p>