Auto Suggest with drop down list selection into text box

Auto Suggest with drop down list selection into text box

Hi Guys, I need help~~~~

I've got a textbox, with a drop down list. This drop down list contains a list of options, when people click on one selection, it gets inserted into the textbox, provided it's not already in there. The script that I used to do this is:

  1. function ddlSuburbs_onClick() { 
          var listBox = document.getElementById('<%= ddlSuburbs.ClientID %>');
          var textbox = document.getElementById('<%= txbSuburb.ClientID %>');
          var totalContent = textbox.value.split("; "); if (textbox.value == '') {
                textbox.value = listBox.options[listBox.selectedIndex].text;
          }
          else {
                for (var i = 0; i < totalContent.length; i++) {
                      if (totalContent[i] == listBox.options[listBox.selectedIndex].text) {
                            return false;
                      }
                }
                textbox.value += "; " + listBox.options[listBox.selectedIndex].text;
          }
          return false;
    }


And this is the drop down list:

  1.  <select id="ddlSuburbs" runat="server" multiple class="suburbs"
              onclick="return ddlSuburbs_onClick()" visible="false" >
    </select>


    <asp:TextBox

    CssClass="long" id="txbSuburb" runat="server" ></asp:TextBox>

Now, I have just used this Auto Suggest plugin, which is pretty cool:

http://code.drewwilson.com/entry/autosuggest-jquery-plugin

The thing is, Auto Suggest now works, but I still wanna keep this drop down list working for users where they can just click on a suburb and it gets inserted into the textbox. Does anyone know how I could archieve this?

I have the JQuery script as:

  1.  $(document).ready(function() { 
                $("#<%=txbSuburb.ClientID %>").autoSuggest("/GetSuburbs.ashx",
                      { selectedItemProp: "name", searchObjProps: "name", asHtmlID:"suburbs" });
    });